アンドロイド用のモーダルテキスト入力ダイアログを作成する最も良い方法は何ですか?Androidでテキスト入力ダイアログを作成するにはどうすればよいですか?
ユーザーがテキストを入力して[OK]ボタンをクリックし、awtのモーダルダイアログのようにダイアログからテキストを抽出するまで、ブロックする必要があります。
ありがとうございます!
アンドロイド用のモーダルテキスト入力ダイアログを作成する最も良い方法は何ですか?Androidでテキスト入力ダイアログを作成するにはどうすればよいですか?
ユーザーがテキストを入力して[OK]ボタンをクリックし、awtのモーダルダイアログのようにダイアログからテキストを抽出するまで、ブロックする必要があります。
ありがとうございます!
この試している:あなたはInputBox関数の種類を意味
final Dialog commentDialog = new Dialog(this);
commentDialog.setContentView(R.layout.reply);
Button okBtn = (Button) commentDialog.findViewById(R.id.ok);
okBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//do anything you want here before close the dialog
commentDialog.dismiss();
}
});
Button cancelBtn = (Button) commentDialog.findViewById(R.id.cancel);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
commentDialog.dismiss();
}
});
reply.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff">
<EditText android:layout_width="fill_parent"
android:layout_gravity="center" android:layout_height="wrap_content"
android:hint="@string/your_comment" android:id="@+id/body" android:textColor="#000000"
android:lines="3" />
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/ok" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="@string/send" android:layout_weight="1"
/>
<Button android:id="@+id/cancel" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_weight="1"
android:text="@android:string/cancel" />
</LinearLayout>
</LinearLayout>
これを追加するとダイアログが表示されます。 commentDialog.show(); – Sahil
なぜそれは残りの同じスタイルを共有しないのですか? – FtheBuilder
XMLレイアウトを使用してカスタムダイアログを作成できます。ユーザーがテキストを入力して[OK]ボタンを押すまでブロックしたい場合は、setCancelable(false)
とすることができます。
Google検索のリンクをチェックしてください:Dialog With EditText
setCancelable(false)は表面的なものですか?本当にすべてをPAUSEできるのですか?私のアプリでは、データが収集され、ダイアログの後ろにあるアクティビティが一時停止されることを願っています。 –
私はあなたがモーダルダイアログボックスを意味すると思います。
私はこう言っています。AlertDialog.Builder開始より新しい方法では、ダイアログライフサイクルをより詳細に制御できるDialogFragmentを使用しています。
あなたが探している鍵方式はdialog.setCancelable(false);
setCancelable(false)は表面的なものですか?本当にすべてをPAUSEできるのですか?私のアプリでは、データが収集され、ダイアログの後ろにあるアクティビティが一時停止されることを願っています。すなわち、データ収集は、ユーザがダイアログを閉じるまで停止される。それを達成するのだろうか? –
@perfectionmingあなたは新しい質問を開く必要があると思います。 –
@perfectm1ng自分のコードで「すべて」を一時停止する必要があります。このモーダルダイアログはあなたのためにできません。おそらく、あなたはcall show()ダイアログの直前にデータ収集を一時停止することができます。 –
を? – Lucifer