how to keep icons in listview in android?

how to keep icons in listview in android?

  • how to keep icons in listview in android?

  • Answer:

    I'm not sure I understand your question. If you want images in a ListView you're going to need to define a custom layout for your list items. You can place an ImageView in that layout and then in your getView or newView/bindView (depending on the Adapter class you extend), you can modify the ImageView to contain whatever graphic you see fit.

deepthi at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Make a new file in /res/layout/demo.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"/> <TextView android:id="@+id/os_name" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> In your class file-- public class MyListActivity extends ListActivity { public void onCreate(Bundle icicle) { super.onCreate(icicle); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, R.id.os_name, values); setListAdapter(adapter); } } In the list you will get the text with image.

Hulk

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.