我无法理解为什么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的消息并没有消失