私はテーマホロダイアログを使用しているアクティビティがあるアンドロイドプロジェクトに取り組んでいます。
ダイアログ内にリストビューがあり、一番下に常に2つのボタンが隣り合った線形レイアウトを表示したいのです。リスト ビューは、呼び出しログからデータを取得し、リストのアダプターを設定することによって設定されます。
私が抱えている問題は、リストビューが常に一番上に表示され、ダイアログ全体が一番下に表示され、リストの内容がボタンに重なっているということです。リストを、ダイアログの上部から線形レイアウト ボタン グループの上部までのスペース内に配置したいと考えています。以下は、メイン コンテンツ ビューのコードです。このレイアウトは onCreate メソッドの setContentView を使用して設定されます
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="wrap_content">
</ListView>
<LinearLayout android:id="@+id/call_log_select_host_button_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<Button android:id="@+id/call_log_select_btnCancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Block"/>
<Button android:id="@+id/call_log_select_btnBlock"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</RelativeLayout>
違いがあるかどうかはわかりませんが、念のため、リストにデータを入力してビューを設定する方法を以下に示します。
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
CallInformation callInformation = (CallInformation)arrayList.get(position);
LayoutInflater inflator = (LayoutInflater)context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflator.inflate(R.layout.call_log_selection, parent, false);
ImageView imageView = (ImageView)rowView.findViewById(R.id.call_log_selector_image);
if (callInformation.type == android.provider.CallLog.Calls.INCOMING_TYPE)
{
imageView.setImageResource(android.R.drawable.sym_call_incoming);
}
else if (callInformation.type == android.provider.CallLog.Calls.OUTGOING_TYPE)
{
imageView.setImageResource(android.R.drawable.sym_call_outgoing);
}
else if (callInformation.type == android.provider.CallLog.Calls.MISSED_TYPE)
{
imageView.setImageResource(android.R.drawable.sym_call_missed);
}
CheckBox checkbox = (CheckBox)rowView.findViewById(R.id.call_log_selector_checkbox);
checkbox.setText(callInformation.content);
checkbox.setTag(callInformation.telephone);
return rowView;
}
}
以下のコードは、アダプターの get view 関数によって拡張された XML レイアウトです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:id="@+id/call_log_selector_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:src="@android:drawable/stat_sys_phone_call"/>
<CheckBox android:id="@+id/call_log_selector_checkbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
ご協力いただきありがとうございます。