Hi Conny, Are you placing the text fields in a layout or just declaring them as provided below. If you are not using a layout enclose these TextViews with in a Layout and try. I guess it should work.
Also try refreshing R.java & build you subset.xml Check if the price variable is reflected in your R.java file. Thanks & Regards, Yousuf Syed On Mon, Jul 12, 2010 at 6:15 AM, Conny <mcon...@gmail.com> wrote: > Crazy behavior in my code. > > I have super.xml and a subset.xml. > > <LinearLayout android:id="@+id/superSet" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:layout_below="@id/titleBarLayout" > android:orientation="vertical"> > <!-- > <include android:id="@+id/row1" > layout="@layout/subset" > /> > <include android:id="@+id/row2" > layout="@layout/subset" > /> > <include android:id="@+id/row3" > layout="@layout/subset" > /> > > --> > </LinearLayout> > > I have commented out the include so that I can dynamically create add > views. > In code I have > > for (int rowCount = 0 ; rowCount < itemSize ; rowCount ++) { > LinearLayout viewEnclosure = new > LinearLayout(mainActivity) ; > listView = (LinearLayout) > mainActivity.getLayoutInflater().inflate(R.layout.subset, null); > > listViewEnclosure.setOrientation(LinearLayout.VERTICAL); > viewEnclosure.addView(listView, new > LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, > > LinearLayout.LayoutParams.WRAP_CONTENT)); > viewEnclosure.setId(rowCount); > viewPlaceHolder.addView(listViewEnclosure, > new > LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, > > LinearLayout.LayoutParams.WRAP_CONTENT)) ; > > Data data = list.get(rowCount) ; > > TextView name = (TextView)listView.findViewById( > R.id.name); > TextView price = (TextView) > listView.findViewById(R.id.price); > TextView quantity = (TextView) > listView.findViewById(R.id.quantity); > name.setText(data.getStrDescription()); > price.setText(data.getStrTotalPrice()) ; > quantity.setText(data.getQuantity()) ; > } > > > subset.xml > <TextView android:id="@+id/name" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:text="Dummy Name" > android:textSize="12dip"> > </TextView> > <TextView android.id="@+id/price" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:textSize="12dip" > android:text="$ 9999999.99"> > </TextView> > <TextView android.id="@+id/quantity" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:text="9999" > android:textSize="12dip"> > </TextView> > > > I get a null pointer exception at > price.setText(data.getStrTotalPrice()) ; > > Very strange, name.setText(data.getStrDescription()); does not give a > null pointer exception. > > Please help > Conny > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en