2010-04-13 3 views
3

특정 항목으로 스크롤되는 목록을 표시해야합니다.ListView and Scroll

어떻게하면됩니까?

오리

+0

검색, 비슷한 질문의 부하가있다 여기에 SO와 Google 모두. –

답변

8

당신이

listView.smoothScrollToPosition(specificPosition); 
7

당신이 다음 목록보기의 setSelection(position)를 호출 할 수 있습니다,리스트 뷰 위젯을 사용하는 supossed된다.

+1

'smoothScroll'이 Android 2.2 이상인 경우이 솔루션을 선호하며 목록이 클 경우 정말 오래 걸릴 수 있습니다. –

-1

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