0
메서드를 사용하여 사용자 지정 Dialog
에 단추를 추가하려고합니다. birthday_friend_contact_dialog.xml
코드 ..사용자 지정 대화 상자에서 목록보기 다음에 단추 추가
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#FFFFFF"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/friend_contact_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp" />
birthday_footerview_button.xml
.. 다음 코드를 사용 ListView
아래에서 정의 Dialog
Button
추가
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/birthday_friend_footer_button"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content" >
<Button
android:id="@+id/cancel_contact_dialog"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Cancel" />
..
final Dialog dialog = new Dialog(AddNewFriend.this);
dialog.setContentView(R.layout.birthday_friend_contact_dialog);
dialog.setTitle("Select Contact...");
ListView contactList = (ListView) dialog
.findViewById(R.id.friend_contact_list);
//////Some code for listview adapter
View footerLayout = (View)dialog.getLayoutInflater().inflate(R.layout.birthday_footerview_button,null);
Button dialogButton = (Button) footerLayout
.findViewById(R.id.cancel_contact_dialog);
contactList.addFooterView(footerLayout);
dialog.show();
그러나 Button
은 ListView
아래에 표시되지 않습니다. 미리 감사드립니다.
있어, 주로의 ListView는 랩 내용에 문제가 있습니다. 고정 높이를 설정하거나 상위와 일치하도록 높이를 설정하십시오. –
ListView 높이를 전체 화면 높이의 백분율로 어떻게 설정할 수 있습니까? – user3384985
높이를 부모와 동일하게 설정하려면 android : layout_height = "match_parent"를 설정하십시오. 그러나 화면 높이의 백분율로 높이를 원하면 프로그래밍 방식으로 높이를 설정할 수 있습니다 (http://stackoverflow.com/questions/2963152/android-how-to-resize-a-custom-view-programmatically). –