gpt4 book ai didi

java - 为什么我的 ListView 不滚动?

转载 作者:行者123 更新时间:2023-12-02 06:56:09 26 4
gpt4 key购买 nike

好吧,我看过其他有同样问题的帖子,但仍然不知道我做错了什么。这是我的代码:

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。它不在 ScrollView 或任何东西内。

文档 ListView :

<?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>

最佳答案

发现这个问题,这是因为我正在扩展一个将所有内容都放在 ScrollView 内的类。不要将 ListView 放在 ScrollView 内

关于java - 为什么我的 ListView 不滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17330384/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com