안드로이드 개발 질문/답변
(글 수 45,052)
다른분께서 질문하시고 답변까지 달렸는데 사용법을 모르겠네요
저분은 저방식으로 해결하셨다고 써있는데 addFooterView를 어떻게 써야하는지좀 알려주시면 감사하겠습니다
======================================================================================
리스트뷰에 아이템들을 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로 설정 해 주었는데도
화면에 꽉찬 리스트 다음에 버튼이 아니라,
한줄 크기의 리스트 뷰에 내부에 스크롤이 생기고, 그아래에 버튼이 붙어 있습니다....
어떤 부분이 잘못되었을까요 ??
=========================================================
밑에 답변이 달렸습니다 헌데 addFooterView 사용법을 모르겠습니다
=========================================================
밑에 답변이 달렸습니다 헌데 addFooterView 사용법을 모르겠습니다
2010.05.04 17:08:29
addFooterView 사용법
ListView listView = getListView();
listView.setAdapter(adapter);
View view = getLayoutInflater().inflate(R.layout.aa, null, false);
listView.addFooterView(view);
어뎁터를 listView에 set하고 나서 addFooterView를 사용하는 것이 관건 입니다.
헌데 이와 같은 방법이라면 요구사항에 맞추기 위해서는 adapter에 있는 item의 갯수가 20개가 항상 유지가 되어야 합니다.
xml 에서 버튼을 화면 하단에 위치하게 하는 방법.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
public void addFooterView (View v)
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
public void addFooterView (View v, Object data, boolean isSelectable)
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