ArrayAdapter使用的Textview佔據了整個屏幕,並且「title」和「description」Textviews沒有顯示......我想在列表前顯示它們,幫助嗎?ArrayAdapter的Textview佔據了所有屏幕
這裏是我的代碼:
TextView titleText = (TextView) this.findViewById(R.id.title);
titleText.setText(sitesList.getTitle());
TextView descriptionText = (TextView) this.findViewById(R.id.description);
descriptionText.setText(sitesList.getDescription());
ArrayList<String> Categories = sitesList.getCategory();
ListView lv = new ListView(this);
lv.setAdapter(new ArrayAdapter<String>(this,R.layout.main,R.id.list_item,Categories));
setContentView(lv);
我的佈局文件是:
<?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"
android:orientation="vertical">
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/list_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
謝謝!
這工作完美,非常感謝你@手稿! :d – miligraf