1
Im在實現片段內部的列表視圖時遇到了麻煩。ListView裏面的片段android
的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功能。 似乎它不是在片段內以這種方式工作。 事情是我需要的第一個視圖將ImageView和第二個是ListView,並在碎片內。
請幫忙,謝謝提前,UDI
事情是我沒有使用ListActivity/ListFragment,因爲我需要第一個視圖將ImageView和之後的列表本身 –
您仍然可以使用ListActivity或ListFragment。但如果你不這樣做,那麼你怎麼使用'setListAdapter()'方法? –
是的,你是對的,我實際上想要使用: listView.setadapter –