我想展示一個toast消息, 但不知為什麼它總是不能被調用時,以下是我的oncreate代碼:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.alarm);
mediaPlayer = MediaPlayer.create(getApplicationContext(),
R.raw.alarmclock);
mediaPlayer.start();
Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG);
}
在使用makeText()後要調用show()來顯示你的信息:
Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG).show();