【发布时间】:2015-01-14 13:04:53
【问题描述】:
我制作了一个自定义的 android toast 并尝试为 textview 定义单击侦听器事件,但它不起作用....有什么帮助吗?
LayoutInflater inflater = LayoutInflater.from(cntxt);
View layout = inflater.inflate(R.layout.toast_layout,null);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(msg);
Toast toast = new Toast(cntxt);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
text.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method s'tub
//didn't go here???
toast.cancel();
}
});
toast.show();
【问题讨论】:
标签: android-toast