I’m trying to code this ListView and I have no idea on how to do it, I have only done simple listview’s using Android built in simple_listview_01.
How would I go around doing this? I already have a Listview xml layout file but, how do I attach it to my code? I know you have to use a textview but, I’m not sure past that.
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:src="@drawable/icon" />
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="My Application" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Simple application that shows how to use RelativeLayout" />
</LinearLayout>
</LinearLayout>
Code so far:
ListView lv = getListView();
/* Gets a ListView */
lv.setTextFilterEnabled(true);
/* sorts the listview */
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getApplicationContext(),
android.R.layout.simple_list_item_1,
result.getheadlines());
setListAdapter(adapter);
see this tutorial it contains list view in every item there is an imageview and 3 textview
hope it will help you