開発メモ/Android/AlertDialogにViewを設定する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*AlertDialogにViewを設定する [#j7e051ed]
AlertDialogにViewを設定することで、カスタマイズしたダイア...
AlertDialogに設定するViewのlayoutのxmlは以下の通りです。~
#codeprettify{{
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/a...
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TimePicker
android:id="@+id/timepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
}}
上記のレイアウトは、DatePickerとTimePickerを持つViewです。~
以下の処理で、AlertDialogで入力した内容を取得できます。
#codeprettify{{
private View dateTimeView = null;
・・・
public boolean onPreferenceClick(Preference preferenc...
LayoutInflater inf = LayoutInflater.from(this);
dateTimeView = inf.inflate(R.layout.datetimedialo...
AlertDialog.Builder dlg = null;
dlg = new AlertDialog.Builder(this);
dlg.setTitle("日時設定");
dlg.setView(dateTimeView);
dlg.setPositiveButton(R.string.lb_grp_btn_ok, thi...
dlg.setNegativeButton(R.string.lb_grp_btn_cancel,...
dlg.show();
return true;
}
@Override
public void onClick(DialogInterface dialog, int which...
switch(which){
case Dialog.BUTTON_POSITIVE:
DatePicker dp = (DatePicker)dateTimeView.find...
TimePicker tp = (TimePicker)dateTimeView.find...
break;
case Dialog.BUTTON_NEGATIVE:
break;
}
}
}}
**参考 [#of5f0f04]
-[[ダイアログは永遠に(1) - AlertDialog>http://ichitcltk.h...
終了行:
*AlertDialogにViewを設定する [#j7e051ed]
AlertDialogにViewを設定することで、カスタマイズしたダイア...
AlertDialogに設定するViewのlayoutのxmlは以下の通りです。~
#codeprettify{{
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/a...
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TimePicker
android:id="@+id/timepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
}}
上記のレイアウトは、DatePickerとTimePickerを持つViewです。~
以下の処理で、AlertDialogで入力した内容を取得できます。
#codeprettify{{
private View dateTimeView = null;
・・・
public boolean onPreferenceClick(Preference preferenc...
LayoutInflater inf = LayoutInflater.from(this);
dateTimeView = inf.inflate(R.layout.datetimedialo...
AlertDialog.Builder dlg = null;
dlg = new AlertDialog.Builder(this);
dlg.setTitle("日時設定");
dlg.setView(dateTimeView);
dlg.setPositiveButton(R.string.lb_grp_btn_ok, thi...
dlg.setNegativeButton(R.string.lb_grp_btn_cancel,...
dlg.show();
return true;
}
@Override
public void onClick(DialogInterface dialog, int which...
switch(which){
case Dialog.BUTTON_POSITIVE:
DatePicker dp = (DatePicker)dateTimeView.find...
TimePicker tp = (TimePicker)dateTimeView.find...
break;
case Dialog.BUTTON_NEGATIVE:
break;
}
}
}}
**参考 [#of5f0f04]
-[[ダイアログは永遠に(1) - AlertDialog>http://ichitcltk.h...
ページ名: