1

フラグメント内にリストビューを実装するのに問題があります。

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="fill_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >


        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/jo_logo" />

    </LinearLayout>

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >
    </ListView>

</LinearLayout>

単純なImageViewとその後のリストビュー。私はすでに実装しようとしました:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity().getBaseContext(), 
            android.R.layout.simple_list_item_1, viewList);
    setListAdapter(adapter);

ここで、viewListはonCreateView関数のView[]です。フラグメント内ではそのように機能していないようです。最初のビューがImageViewで、2番目のビューがListViewであり、すべてフラグメント内にある必要があります。

助けてください、事前に感謝します、udi

4

1 に答える 1

2

レイアウトxmlをに変更android:id="@+id/listView1"します。android:id="@android:id/list"そうしないと、ListActivity/ListFragmentはあなたのを見つけられませんListView

于 2012-08-23T13:33:02.690 に答える