我在我的应用程序中显示警报对话框,只有按下返回按钮才会显示 我可以在短时间内制作它,然后它会自动像Toast一样
答案 0 :(得分:0)
希望这段代码有用! ;)更新
public class MainActivity extends AppCompatActivity {
AlertDialog ad;
AlertDialog.Builder adb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adb = new AlertDialog.Builder(MainActivity.this);
adb.setTitle("TITLE");
adb.setMessage("MSG");
ad = adb.create();
ad.show();
new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
ad.dismiss();
Toast.makeText(MainActivity.this,"YourToast",
Toast.LENGTH_SHORT).show();
}
}.start();
}
}