有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何编写这个Listview?

我正在尝试编写这个ListView,但我不知道怎么做,我只使用Android内置的simple_ListView_01完成了simple ListView

我该怎么做呢?我已经有了一个Listview xml布局文件,但如何将其附加到代码中?我知道你必须使用文本视图,但我不确定你是否已经使用了文本视图

XML:

<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:layout_width="fill_parent"
    安卓:layout_height="?安卓:attr/listPreferredItemHeight"

    安卓:padding="6dip">

    <ImageView
        安卓:id="@+id/icon"

        安卓:layout_width="wrap_content"
        安卓:layout_height="fill_parent"
        安卓:layout_marginRight="6dip"

        安卓:src="@drawable/icon" />

    <LinearLayout
        安卓:orientation="vertical"

        安卓:layout_width="0dip"
        安卓:layout_weight="1"
        安卓:layout_height="fill_parent">

        <TextView
            安卓:layout_width="fill_parent"
            安卓:layout_height="0dip"
            安卓:layout_weight="1"

            安卓:gravity="center_vertical"
            安卓:text="My Application" />

        <TextView  
            安卓:layout_width="fill_parent"
            安卓:layout_height="0dip"
            安卓:layout_weight="1" 

            安卓:singleLine="true"
            安卓:ellipsize="marquee"
            安卓:text="Simple application that shows how to use RelativeLayout" />

    </LinearLayout>

</LinearLayout>

迄今为止的代码:

ListView lv = getListView();
                /* Gets a ListView */
                lv.setTextFilterEnabled(true);

                /* sorts the listview */
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                        getApplicationContext(),
                        安卓.R.layout.simple_list_item_1,
                        result.getheadlines());
                setListAdapter(adapter);

共 (0) 个答案