textview的onClick事件没有发生

时间:2014-01-24 17:18:27

标签: java android eclipse

我无法理解为什么textview的onClick事件没有发生? 我的代码:

public class CallReceiver extends BroadcastReceiver{    
Context my_ctx;
private static CountDownTimer countDownTimer;   
private static Toast my_toast;

public void onReceive(Context context, Intent intent) 
{
    my_ctx = context;
    showing_toast("Message");
}

public void showing_toast(String Message)
{       
my_toast  = Toast.makeText(my_ctx, Message, Toast.LENGTH_SHORT);
    TextView textView = new TextView(my_ctx);
    textView.setText(Message);  

    textView.setOnClickListener(new OnClickListener() {
         @Override
         public void onClick(View v) {
                countDownTimer.cancel();                                                 
         }
        });

    my_toast.setView(textView);

    countDownTimer  = new CountDownTimer((30)*1000, 1000) {
          @Override
          public void onTick(long millisUntilFinished) {
            my_toast.show();
        }
        @Override
        public void onFinish() {                
            my_toast.cancel();
        }
    }.start();  

}   

所以,countDownTimer继续播放,虽然我点击了textview,但是toast的消息并没有消失

0 个答案:

没有答案