吐司没有显示出来

时间:2012-07-16 19:10:48

标签: android toast

我想要显示一个Toast消息,但不知何故它没有被调用,下面是我的oncreate Code。

   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);
    }

3 个答案:

答案 0 :(得分:4)

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

Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG).show();

答案 1 :(得分:0)

你错过了

Toast.makeText(your_activity.this, "u clicked me", Toast.LENGTH_SHORT).show();

答案 2 :(得分:0)

一个已知的错误...... 你忘了添加show()方法。 应该是

Toast.makeText(this, "Alarm time up", Toast.LENGTH_LONG).show();
相关问题