0
アンドロイドスタジオにアラートボックスを作成しようとしています。ボタンをクリックするともう1つのレイアウトを表示する2つのxmlと1つのアクティビティクラスがあります。 私はエラーを取得しています、ここMainActivity私はアンドロイドスタジオにアラートボックスを作成しています
このラインでcancelBookingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = getLayoutInflater();
View alertLayout = inflater.inflate(R.layout.alert_cancel_confirm, null);
final TextView disAgree = (TextView) alertLayout.findViewById(R.id.TextDisagree);
final TextView Agree = (TextView) alertLayout.findViewById(R.id.TextAgree);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Current Booking");
// This will set the view from XML inside ALertDialog
alert.setView(alertLayout);
// disabling cancel of AlertDialog on click of back button and outside touch
alert.setCancelable(false);
AlertDialog dialog = alert.create();
dialog.show();
}
});
の私のコードは、私がエラーBuilderで
AlertDialog.Builder alert = new AlertDialog.Builder(this);
を適用することはできません 私はこれを取得していますなぜすべてのアイデアを取得しています。
'新しいAlertDialog.Builder(MainActivity.this)を試してみてください;' 'どこMainActivity'は、このコードがである、アクティビティのクラス名です – Titus
あなたもカスタムダイアログでこれを達成することができます@Firdoeshkhan。 。 – Dhiraj