好的,所以我查看了其他具有相同问题的帖子,但仍然无法弄清楚我做错了什么。这是我的代码:
ListView list = (ListView) getView().findViewById(R.id.listView);
String[] stringArray = new String[] { "Bright Mode", "Normal Mode","Bright Mode",
"hey Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode",
"hey Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode",
"hey Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","Bright Mode",
"hey Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode","end", "Bright Mode", "Normal Mode","Bright Mode",
"hey Mode","Bright Mode", "Normal Mode","Bright Mode", "Normal Mode", "end2" };
ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(getView().getContext(), R.layout.document_list_view, stringArray);
list.setAdapter(modeAdapter);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Toast.makeText(getView().getContext(), "Clicked", Toast.LENGTH_LONG).show();
}
});
单击工作正常,但内容会离开屏幕,它不会让我滚动。这是我的 XML。它不在滚动视图或任何东西内。
文档列表视图:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/listText"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:textColor="@color/black">
</TextView>
页面布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1000dp"
android:layout_height="600dp">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>