简体   繁体   中英

How would I code this Listview?

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);

You should read more the ListView tutorial here . The link explains the comprehensive material for the list view.

看到本教程,它在每个项目中都包含列表视图,并且有一个imageview和3个textview希望对您有所帮助

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM