我已经下载了AppRate(https://github.com/TimotheeJeannin/AppRate),并用它来提示一个对话框,要求用户在特定的#次启动后对用户进行评分。时间流逝。它到目前为止工作正常.. 唯一的问题是,我想将它与自定义布局(在XML文件上烹饪)合并,因此对话框看起来与标准应用程序主题不同。 是否可能?
代码:
private void showDefaultDialog() {
Log.d(TAG, "Create default dialog.");
String title = "Rate " + getApplicationName(hostActivity.getApplicationContext());
String message = "If you enjoy using " + getApplicationName(hostActivity.getApplicationContext()) + ", please take a moment to rate it. Thanks for your support!";
String rate = "Rate it !";
String remindLater = "Remind me later";
String dismiss = "No thanks";
new AlertDialog.Builder(hostActivity)
.setTitle(title)
.setMessage(message)
.setPositiveButton(rate, this)
.setNegativeButton(dismiss, this)
.setNeutralButton(remindLater, this)
.setOnCancelListener(this)
.create().show();
}
非常感谢你。
答案 0 :(得分:0)
以下是一个示例,您可以在custom_dialog.xml中编写任何您想要的内容
public class CustomDialog extends DialogFragment {
public CustomDialog() {
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.custom_dialog, null);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.setCancelable(true);
return dialog;
}
}
要显示对话框,请使用此代码
CustomDialog dialog = new CustomDialog();
dialog.show(context, CustomDialog.class.getName());