oriharel
oriharel

Reputation: 10468

ListView and Scroll

I need to show a list that is scrolled to a specific item.

how can I do it?

Ori

Upvotes: 3

Views: 1778

Answers (3)

Android
Android

Reputation: 9033

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

Upvotes: -1

Alexander Voloshyn
Alexander Voloshyn

Reputation: 924

you can use

listView.smoothScrollToPosition(specificPosition);

Upvotes: 8

caligari
caligari

Reputation: 2128

It is supossed you are using a ListView widget, then you can call setSelection(position) of the listview.

Upvotes: 7

Related Questions