ダイアログを表示しようとしています。しかし、私はそれをビューの右下に表示したいので、ダイアログがそこにとどまっている間にアクティビティを使用したいと思います。どうすれば解決できますか?右下にAndroidの警告ダイアログが表示され、表示されている間にアクティビティを使用します。
これは私が
何を得る。これは、私が
欲しいものですされ、必要に応じて、これは私のDialogFragmentクラスです:
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
public class FireMissilesDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("Test")
.setPositiveButton("Fire", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// FIRE ZE MISSILES!
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}
助けてくれてありがとう:)
私はあなたがダイアログと一緒に行くべきではないと思う、テキストとボタンを使ってビューを作成し、それを右下に置くべきだ。ダイアログは、アクションが実行されるまでアクティビティを一時停止します。 –
@BojanKseneman良い解決策ですが、プロジェクトで複数のアクティビティがあり、それぞれにテキストとボタンを追加することは本当に難しいでしょう。 –
あなたはColupを使用し、次にPopupWindow [https://developer.android.com/reference/android/widget/PopupWindow.html]を使用します。あなたはどこにいてもその位置を設定することができます。 Googleの例では、私はそれらのトンがあると確信しています。 –