ListView and Scrolling

I need to show a list that scrolls to a specific item.

How can i do this?

Op

+3
source share
3 answers

you can use

listView.smoothScrollToPosition(specificPosition);
+8
source

It is assumed that you are using a ListView widget, then you can call setSelection (position) on the list.

+7
source

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            style="?whiteBackground">



        </LinearLayout>
        <TextView android:id="@+id/textView1" android:layout_width="fill_parent" style="?textTitle" android:layout_height="wrap_content" android:text="Contents"></TextView>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="the following is content..."
            style="?textSubheader"/>

        <!-- You cannot have a ListView inside of a ScrollView. This LinearLayout acts like one. -->
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            >
->
            <ListView android:id="@+id/lv" android:textColor="#444444"
                android:layout_height="270dip" 
                 android:textStyle="bold"


                android:cacheColorHint="#00000000" android:dividerHeight="2px"
                android:layout_marginTop="5px" android:layout_width="fill_parent"
                android:textSize="5px" android:layout_gravity="center">
            </ListView>
<TextView android:id="@+id/any_old_widgetqss" 
    android:layout_width="fill_parent" style="?textTitle"
    android:layout_height="40px" android:text="MCMS" android:background="@drawable/colorr"></TextView>

        </LinearLayout>

    </LinearLayout>

</ScrollView>
-1
source

Source: https://habr.com/ru/post/1740905/


All Articles