0

我想显示一条 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);
    }
4

3 回答 3

4

您必须在使用 makeText() 后调用 show() 来显示您的消息:

Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG).show();
于 2012-07-16T19:12:13.980 回答
0

你不见了

Toast.makeText(your_activity.this, "u clicked me", Toast.LENGTH_SHORT).show();
于 2012-07-16T19:13:32.343 回答
0

一个已知的错误...您忘记添加 show() 方法。应该

Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG).show();
于 2012-07-16T19:13:53.760 回答