我在我的应用程序中有一个自定义对话框。我的自定义对话框实现为具有透明背景和类似于对话框视图的Activity。我的自定义对话框看起来像警告对话框,带有标题、消息和按钮。我想要做的是创建一个漂亮的界面来设置我的弹出窗口的标题、消息和onClickListener。
首先,我想把所有的东西都放到意图中,如下:
Intent intent = new Intent (this, CustomPopup.class);
intent.putExta ("Title", "PopupTitle");
intent.putExta ("Message", "PopupMessage");
intent.putExtra ("OnCLickListener", ?????); //here is problem
startActivity(intent);
但问题是没有办法将OnCLickListener设置到意图中。
其次,我尝试创建一个实现Parcable接口的类。但问题仍然存在。
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(message);
dest.writeValue(buttonClickListener); // here is problem. I cannot write Interface
}
我无法将OnCLickListener写入Parcel对象。
如何实现?如何为我的自定义弹出窗口编写漂亮的界面?因为弹出窗口可以有不同的标题和消息,并且弹出窗口将在许多活动中使用...提前致谢。
true
的额外选项呢?如果设置为true,则在接收的Activity
类中创建OnClickListener()
。 - tolgap