-1

I want to scroll listview.But Listview only scrolls when item of listview exceeded the length of screen .But I want to scroll listview whether listview have one item or ten.I have used this code but it's not working,also have searched a lot but there is no tutorial about this found.So please suggest me how to do this.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingTop="10dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

        <EditText
            android:id="@+id/etSearch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="98"
            android:background="@drawable/search_shape"
            android:cursorVisible="false"
            android:gravity="center"
            android:imeOptions="actionSearch"
            android:singleLine="true" >
        </EditText>

        <Button
            android:id="@+id/SearchBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@drawable/search_selector" />
    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ListView
            android:id="@+id/listView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/moreBtn"
            android:layout_below="@+id/etSearch"
            android:scrollbarStyle="outsideInset"
            android:layout_marginTop="10dp" >
        </ListView>

        <Button
            android:id="@+id/moreBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@drawable/more_selector"
            android:visibility="gone" />

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="invisible" />
    </RelativeLayout>

</LinearLayout>
Dilip
  • 2,271
  • 5
  • 32
  • 52
  • Can you show your whole XML file code(BTW whts the need to scroll List when there is only one Item) – Chintan Raghwani Jun 27 '12 at 11:49
  • @ChintanRaghwani i have updated my question, have a look. – Dilip Jun 27 '12 at 11:50
  • see @chintan i want to develop this listview like listview developed in Adobe Flex and listView of Nokia Lumia.In flex listview if listItem is only one even you can scroll(pull) it up to layout bottom.I hope now you got my requirement – Dilip Jun 27 '12 at 11:55
  • simply change your listview height to wrap_content android:layout_height="wrap_content" – Furqi Jun 27 '12 at 12:23
  • i have changed listview layout_height="wrap_content" even its not scrolling........... – Dilip Jun 27 '12 at 12:55

2 Answers2

0

I found 1 solution, it is called Pull-To-Referesh

How to implement Android Pull-to-Refresh

U can download from followin https://github.com/erikwt/PullToRefresh-ListView (Thanks to Erik Wallentinsen) But It is not working properly.

So, I made some needed changes to it and prepared one proper working demo.

Community
  • 1
  • 1
Chintan Raghwani
  • 3,370
  • 4
  • 22
  • 33
  • Just add your location and email-id to your stack-overflow profile. – Chintan Raghwani Jun 27 '12 at 17:52
  • Thank you so much @Chintan .This is what exactly i was looking for .But there is an error when run app Android library project can not be launched.So please suggest me about this – Dilip Jun 28 '12 at 06:03
-1

You can try this XML code.

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
   <ListView
   android:id="@+id/listView"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:layout_above="@+id/moreBtn"
   android:layout_below="@+id/etSearch"
   android:scrollbarStyle="outsideInset"
   android:layout_marginTop="10dp" >
   </ListView>
</ScrollView>
Bala
  • 445
  • 5
  • 11
  • 26