안드로이드 개발 질문/답변
(글 수 45,052)
리스트뷰에 아이템들을 20개 이상 삽입하고 , 그 리스트가 끝나는 지점에 버튼을 하나 삽입하고 싶습니다.
그래서 아래와 같이 xml을 구성했습니다.
< ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView android:id="@+id/list_content"
android:layout_width="fill_parent" android:layout_height="wrap_content">
</ListView>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/bt_more"
android:text="@string/bt_name_more"></Button>
</LinearLayout>
</ScrollView >
LinearLayout의 height 사이즈를 fill_parent로 설정 해 주었는데도
화면에 꽉찬 리스트 다음에 버튼이 아니라,
한줄 크기의 리스트 뷰에 내부에 스크롤이 생기고, 그아래에 버튼이 붙어 있습니다....
어떤 부분이 잘못되었을까요 ??
2010.01.18 23:43:13
ScrollView 내에 ListView를 넣는 것은 가급적 사용하지 않는 것이 좋습니다. 성능에 좋지 않다고 하네요.
대신 요놈을 사용해보세요.
public void addFooterView (View v)
Since: API Level 1
Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
Parameters
v | The view to add. |
---|
public void addFooterView (View v, Object data, boolean isSelectable)
Since: API Level 1
Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
Parameters
v | The view to add. |
---|---|
data | Data to associate with this view |
isSelectable | true if the footer view can be selected |
ListView 한줄 정도의 height에 스크롤이 생길 것 같아 보이는데요.^^