0
我想通過數組適配器綁定我的列表視圖。我有我的ListView的佈局無法查看列表視圖
activity_menu.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<ImageView android:layout_height="wrap_content"
android:layout_width = "wrap_content"
android:src="@drawable/saltnpepper"
android:layout_weight="1"
android:scaleType="centerInside"/>
</TableRow>
<TableRow android:paddingTop="@android:dimen/app_icon_size"><TextView></TextView></TableRow>
<TableRow>
<ListView android:id="@+id/list1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="10dp">
</ListView>
</TableRow>
</TableLayout>
然後我有TextView的另一個佈局在ListView
menulist.xml
加載<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/nameText"
android:text="@string/app_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="16sp"
android:textStyle="bold"/>
在我的代碼我做以下,但我的列表視圖中從來沒有一次加載
ArrayList<String> alTest = new ArrayList<String>();
alTest.add("One");
alTest.add("Two");
ArrayAdapter<String> catAdapter = new ArrayAdapter<String>(this, R.layout.menulist, R.id.nameText, alTest);
ListView list = (ListView)findViewById(R.id.list1);
list.setAdapter(catAdapter);
我也曾嘗試簡單的數組,而不是ArrayList的alTest但沒有工作
你的東西在你的'Logs'表演之謂也。 –