当我从gcm收到通知时,我需要提出一个警告对话框,其中包含该对话框中的事件列表。我通过使用自定义Toast消息来执行此操作。但我无法在列表中编写单击事件警告对话框。 当我收到新的notification.alert对话框时,我会调用此方法,但onclick事件不适用于列表..
public void displayToast()
{
LayoutInflater mInflater = LayoutInflater.from(con);
View myView = mInflater.inflate(R.layout.statusbar, null);
Toast toast = new Toast(con.getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
TextView tv = (TextView) myView.findViewById(R.id.notificationtype);
ListView lv = (ListView) myView.findViewById(R.id.listView1);
lv.setAdapter(new StatusAdapter(con, list));
tv.setText("MESSAGES");
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
// TODO Auto-generated method stub
if (list.get(arg2).getType().equals("S Notification")) {
Intent it = new Intent(con,ViewEventActivity.class);
it.putExtra("eventid", list.get(arg2).getId());
it.putExtra("event", "team");
con.startActivity(it);
//dialog.dismiss();
}
if (list.get(arg2).getType().equals("S R Notification")) {
Intent it = new Intent(con,GameDetailsActivity.class);
it.putExtra("id", list.get(arg2).getId());
con.startActivity(it);
//dialog.dismiss();
}
if (list.get(arg2).getType().equals("A Notification")) {
Intent intent = new Intent(con,ViewItemActivity.class);
intent.putExtra("id", "" + list.get(arg2).getId());
con.startActivity(intent);
//dialog.dismiss();
}
if (list.get(arg2).getType().equals("D Notification")) {
Intent it = new Intent(con,PersonalDetails.class);
it.putExtra("personId", list.get(arg2).getId());
con.startActivity(it);
//dialog.dismiss();
}
if (list.get(arg2).getType().equals("M Notification")) {
Intent it = new Intent(con,MessageContentActivity.class);
it.putExtra("messageid", list.get(arg2).getId());
con.startActivity(it);
// dialog.dismiss();
}
}
});
toast.setDuration(Toast.LENGTH_LONG);
toast.setDuration(1800000);
toast.setView(myView);
toast.show();
}
答案 0 :(得分:0)
Toast Window具有由框架
设置的属性WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
因此,您拥有的任何视图都无法向其发送事件。