2010-01-08 6 views
0

ScrollView에 약간의 문제가 있습니다. ScrollView로 만든 활동을위한 레이아웃이 있습니다. 이 scrollview는 두 개의 ListView를 포함합니다. 내 활동의 onCreate 방법에서 프로그래밍 방식으로 ScrollView를 스크롤하는 방법은 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/rootViewGroup" android:layout_width="fill_parent" 
android:layout_height="wrap_content" android:scrollbars="vertical"> 

<LinearLayout android:orientation="vertical" 
    android:gravity="top" android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:background="@drawable/cmb_bg"> 

    <ListView android:id="@+id/accountsListView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:scrollbars="none" /> 

    <ListView android:id="@+id/cardsListView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:scrollbars="none" /> 

</LinearLayout> 

나는 그 내용을 따라의 ListView의 높이를 계산한다.

실행 중에 활동을 시작하면 ScrollView가 이미 약간 스크롤됩니다.

그래서 내가 시도한 끝에 메서드 scrollTo(0, 0)을 호출하기 위해 onCreate를 시도했지만 아무 것도 변경하지 않았습니다.

아이디어가 있으십니까?

답변

6

AHHH !!! ScrollView를 제거하고 하나의 ListView 만 활동에 남겨 둡니다. 이 방법으로 작동하지 않으려 고합니다 . 하나의 목록보기에 다른 콘텐츠가 있기를 원한다면 어댑터를 수정하거나 UI를 변경하십시오. 다른 화면으로 스크롤 할 수있는 컨테이너를 두지 마십시오. 여기 있습니다. 관련 게시물. http://groups.google.com/group/android-developers/browse_thread/thread/e7c8df374fe31733# 이론적으로 두리스트 뷰를 화면에서 볼 수 있지만 이상하게 보일 수 있습니다. 그리고 나는 분리 자 또는 확장자 또는 하나의 ListView를 사용하여 실제로 재 설계 할 것입니다.

+0

제프 샤키 (Jeff Sharkey)가 구부리거나 굽힐 수있는 아주 좋은 예가 있습니다 http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android- 09 / –

관련 문제