I have a Customised ListView which contains ImageView and TextView.
I want to get instance of the TextView in onCreate().
I tried, but m getting NullPointerException….
Can anybody please help me out…..
Here’s the code m working with…
delete_list.xml
Using xml Syntax Highlighting
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#ffffff"
- >
- <ListView
- android:id="@+id/DELETE_LIST"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:choiceMode="multipleChoice"
- android:clickable="true"
- />
- </RelativeLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
custom_list.xml
Using xml Syntax Highlighting
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <ImageView
- android:id="@+id/LIST_IMAGE"
- android:layout_width="140px"
- android:layout_height="70px"
- android:layout_alignParentLeft="true"
- android:layout_marginTop="5px"
- android:src="@drawable/below_image_online"
- />
- <TextView
- android:id="@+id/LIST_DELETE_ICON"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_marginRight="5px"
- android:layout_marginTop="5px"
- android:text="i"
- />
- </RelativeLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
And Here’s the Java File
Using java Syntax Highlighting
- public class DeleteList extends Activity {
- ListView myList;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.delete_list);
- mBuddyList = (ListView) findViewById(R.id.DELETE_LIST);
- ArrayList<HashMap<String, String>> arrList = new ArrayList<HashMap<String, String>>();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Image",R.drawable.image1);
- map.put("Text","Delete");
- arrList.add(map);
- map = new HashMap<String, String>();
- map.put("Image",R.drawable.image2);
- map.put("Text","Delete");
- arrList.add(map);
- map = new HashMap<String, String>();
- map.put("Image",R.drawable.image3);
- map.put("Text","Delete");
- arrList.add(map);
- map = new HashMap<String, String>();
- map.put("Image",R.drawable.image4);
- map.put("Text","Delete");
- arrList.add(map);
- SimpleAdapter myAdapter = new SimpleAdapter(this,arrList,R.layout.custom_list,new String[]{"Image","Text"},new int[]{R.id.LIST_IMAGE,R.id.DELETE_ICON});
- mList.setAdapter(myAdapter);
- TextView deleteIcon = (TextView) mList.findViewById(R.id.LIST_DELETE_ICON);
- // here i get deleteIcon as null
- }
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
please help me out...



