0

これが再投稿であることは知っていますが、これを何年も(何時間も)機能させようとしてきましたが、既存の回答を本当に理解できません。私が知りたいのは、このコードを編集して機能させるにはどうすればよいですか? 2 つの異なる配列から両方のテキストビューを作成しようとしています。

2 番目のアダプターのみが読み取られ、最初のアダプターのテキストビューは空白のままになります。

どんな助けでも大歓迎です。

        public void run () {                

            if (t.getState() == Thread.State.TERMINATED) {
                adapter2 = new ArrayAdapter<String>(getApplicationContext(), R.layout.listlook, R.id.txtl2, names);
                setListAdapter(adapter2);
                adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.listlook, R.id.txtl1, comments);
                setListAdapter(adapter);
                return;
            } else {
                h.postDelayed(this, 1000);  
            }

        }}
    , 1000);    
}

前もって感謝します。

Usercomments.xml 内のリストビュー

            <ListView
            android:id="@+android:id/list"
            android:layout_width="match_parent"
            android:layout_height="150dp" >
            </ListView>

listlook.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

    <TextView
    android:id="@+id/txtl1"
    android:paddingLeft="2dp"
    android:textSize="20sp"
    android:textStyle="bold"
    android:textColor="#0000FF"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />

    <TextView
    android:id="@+id/txtl2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtl1"
    android:gravity="bottom|right"
    android:paddingLeft="5dp"
    android:text="TextView"
    android:textColor="#5C002E"
    android:textSize="15sp" />

    </RelativeLayout>

listlook は、リストビューで使用する単なるレイアウトですか? 私が何をしているのかよくわかりません。

4

2 に答える 2

0

で2行ありsetListAdapter()ます。2 番目は 1 番目を上書きします。2 つある場合は、次のListViewsようにします。

listView1.setListAdapter(adapter2);
listView2.setListAdapter(adapter);
于 2013-10-20T20:22:25.760 に答える