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 Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en