开发者

my android listview doesn't scroll

开发者 https://www.devze.com 2023-04-11 19:17 出处:网络
i\'m trying to make a program that has a listview widget which shows some items that i fetch from a database. I set an arrayadapter for my listview, it shows the elements but doesn\'t scroll down or u

i'm trying to make a program that has a listview widget which shows some items that i fetch from a database. I set an arrayadapter for my listview, it shows the elements but doesn't scroll down or up. Here is my code and btw i'm using an android 2.3.3 avd.

ListView lv;
开发者_高级运维lv = (ListView)findViewById(R.id.listView1);
String[] liste = new String[suggestion.size()];
//liste is populated afterwards, there are about 100 items
ArrayAdapter<String> adapterForList = new ArrayAdapter<String>(getApplicationContext(),R.layout.listview,R.id.word,liste );
lv.setAdapter(adapterForList);

and here is my listview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
<TextView
        android:id="@+id/word"
        style="@android:style/TextAppearance.Large"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

and here is the main xml file that activity uses. the above one is for just the listview widget.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></Spinner>
    <EditText android:id="@+id/etSQL" android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </EditText>
</LinearLayout>


<ListView android:layout_width="fill_parent" android:id="@+id/listView1"
    android:layout_height="0dp" android:layout_weight="1"></ListView>
</LinearLayout>


Your XML doesn't contain any ListView...


there is an interesting situation. Code is running, if I understand it; only problem is scrolling.. :)) (Wrong xml file)


problem was because of a spinner in the program. idk why but it worked after i have removed the spinner.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号