안드로이드 개발 질문/답변
(글 수 45,052)
데이터베이스에서 레코드를 받아와서 리스트뷰로 보이게 하고 클릭하면 상세정보를 볼 수 있도록 하려고 합니다. 일단은 데이터베이스값을 읽어오는 기능만 넣으려고 하는데요. 맨 아래 버튼 하나를 고정시켜 두고 이 'load 기능 버튼'을 누르면 버튼 위 공간에 리스트뷰가 나오도록 하고 싶습니다.
근데 main.xml을 어떻게 짜면 그런 레이아웃을 만들 수 있는지 도무지 모르겠군요. LinearLayout으로 해놓고 리스트뷰와 버튼을 그 안에 넣고 layout_weight를 리스트뷰는 1로, 버튼은 없는 걸로 해 보았는데 원하는 레이아웃이 안나와 여러가지 시도를 해봤는데 여의치 않습니다.
고수님들 좋은 방법이 있으면 알려주시면 감사하겠습니다.
(공지사항 잘 읽었습니다)
근데 main.xml을 어떻게 짜면 그런 레이아웃을 만들 수 있는지 도무지 모르겠군요. LinearLayout으로 해놓고 리스트뷰와 버튼을 그 안에 넣고 layout_weight를 리스트뷰는 1로, 버튼은 없는 걸로 해 보았는데 원하는 레이아웃이 안나와 여러가지 시도를 해봤는데 여의치 않습니다.
고수님들 좋은 방법이 있으면 알려주시면 감사하겠습니다.
(공지사항 잘 읽었습니다)
2010.06.17 10:48:08
원하시는 Layout 설정입니다. 테스트 해보세요
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<TextView android:id="@id/android:empty" android:text="no data" android:layout_width="fill_parent" android:gravity="center" android:layout_height="fill_parent" android:layout_weight="99"></TextView>
<ListView android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@id/android:list" android:layout_weight="1"></ListView>
<Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
</LinearLayout>
2010.06.17 13:01:34
윗분 방식 처럼 하셔도 되는데 리스트가 길어지면 버튼을 덮어버리게 됩니다. 그럴땐 FrameLayout 사용하세요.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/select_contect_layout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/select_contect_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding = "4dip" android:layout_weight="1" android:layout_marginBottom="50dip" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom" > <Button android:id="@+id/select_contect_load_btn" android:text="load" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> </FrameLayout> </LinearLayout>