无法查看列表视图
问题描述:
我想通过数组适配器绑定我的列表视图。我有我的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但没有工作
答
所以问题不是那个listview没有加载,但它之前的imageview覆盖更多的屏幕!还有现在我有一个问题(张贴在一个新的线程)
<TableRow android:layout_weight="1" android:gravity="center">
<ImageView android:layout_height="200dp"
android:layout_width = "match_parent"
android:src="@drawable/saltnpepper"
android:scaleType="centerInside" />
</TableRow>
图像不列入扩大屏幕的整个宽度
你的东西在你的'Logs'表演之谓也。 –