I am trying to add an icon in the list view. Below is my code snippet and realted xml, without the icon(i.e. just list view).
Code: final View addUser = factory.inflate(R.layout.addusers, null); mEditText = (EditText)addUser.findViewById (R.id.EditText_UserName); builder = new AlertDialog.Builder(this); builder.setView(addUser); builder.setTitle(R.string.dialog_addusers_title); builder.setIcon(R.drawable.adduser); builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mStrings.add(0, mEditText.getText().toString()); mEditText.setText(""); lap.notifyDataSetChanged(); } }); builder.setNegativeButton(R.string.button_cancel,null); alertDialog = builder.create(); dialog = alertDialog; myListView = (ListView)findViewById(R.id.ListView_UserList); lap = new ArrayAdapter<String>(this, R.layout.userlist, mStrings); Original "userlist.xml" <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="7dp" android:singleLine="true"/> Then I tried to add the image view widget to add my icon in each list. Modified "userlist.xml" <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView xmlns:android="http://schemas.android.com/apk/res/ android" android:id="@+id/ImageView_UserIcon" android:layout_width="48dp" android:layout_height="48dp" android:layout_alignParentLeft="true" android:layout_marginRight="7dp" android:layout_marginTop="7dp" android:scaleType="fitXY" android:src="@drawable/carol"/> <TextView android:id="@+id/TextView_UserName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="7dp" android:singleLine="true"/> </LinearLayout> But I am not successful. It is crashing. Any suggestion on how to add icons in the list view? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---