Hi Vishal,

  If you want to make custom list view just use the base adapter for
list with icons as greg mentioned above.

Gulfam


On Sep 3, 5:44 pm, "Vishal.Android" <vishal.andr...@gmail.com> wrote:
> Thanks Greg, that was very helpful.
>
> On Sep 2, 8:54 pm, greg <sep...@eduneer.com> wrote:
>
> > Have you reviewed List14 in the API demos?
>
> > On Sep 2, 11:47 am, Vishal Gaonkar <vishal.andr...@gmail.com> wrote:
>
> > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to