Java 如何制作一个;Don';t不再显示此警告消息“;对话框弹出框
我正在尝试创建一个对话框,在我的应用程序中显示一条介绍消息,下面有一个“不再显示此消息”复选框。Java 如何制作一个;Don';t不再显示此警告消息“;对话框弹出框,java,android,android-layout,Java,Android,Android Layout,我正在尝试创建一个对话框,在我的应用程序中显示一条介绍消息,下面有一个“不再显示此消息”复选框。 我不知道如何编写代码 这是我的java代码 这是我的layout.xml代码 祝你度过愉快的一天:)我很抱歉回答得太晚,但你的问题是 您可以使用共享首选项轻松解决此问题 详情如下: 以及守则: AlertDialog.Builder adb= new AlertDialog.Builder(this); LayoutInflater adbInflater =
我不知道如何编写代码 这是我的java代码 这是我的layout.xml代码
祝你度过愉快的一天:)我很抱歉回答得太晚,但你的问题是
您可以使用共享首选项轻松解决此问题
详情如下: 以及守则:
AlertDialog.Builder adb= new
AlertDialog.Builder(this);
LayoutInflater adbInflater =
LayoutInflater.from(this);
View eulaLayout = adbInflater.inflate
(R.layout.activity_main, null);
check = (CheckBox)
eulaLayout.findViewById(R.id.skip);
adb.setView(eulaLayout);
adb.setTitle("Example:");
adb.setMessage(Html.fromHtml("Type your
text here: "));
adb.setPositiveButton("Ok", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which) {
String checkBoxResult = "NOT
checked";
if (check.isChecked())
checkBoxResult = "checked";
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor
editor = settings.edit();
editor.putString("noshow",
checkBoxResult);
// Commit the edits!
// sunnovalthesis();
editor.commit();
return;
} });
adb.setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which) {
String checkBoxResult = "NOT
checked";
if (check.isChecked())
checkBoxResult = "checked";
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor =
settings.edit();
editor.putString("noshow",
checkBoxResult);
// Commit the edits!
// sunnovalthesis();
editor.commit();
return;
} });
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
String noshow = settings.getString
("noshow", "NOT checked");
if (noshow != "checked" ) adb.show();
快乐编码 如果你能告诉我们什么是有效的,什么是无效的,对你会更有帮助。你从来没有问过我不知道如何编写代码的问题。很抱歉
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10.0dip" >
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/brick_warning"
android:textSize="15dp" />
</RelativeLayout>
<CheckBox
android:id="@+id/dont_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dont_show"
android:textSize="13dp" />
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/okay"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/dialog_continue" />
</LinearLayout>
</LinearLayout>
AlertDialog.Builder adb= new
AlertDialog.Builder(this);
LayoutInflater adbInflater =
LayoutInflater.from(this);
View eulaLayout = adbInflater.inflate
(R.layout.activity_main, null);
check = (CheckBox)
eulaLayout.findViewById(R.id.skip);
adb.setView(eulaLayout);
adb.setTitle("Example:");
adb.setMessage(Html.fromHtml("Type your
text here: "));
adb.setPositiveButton("Ok", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which) {
String checkBoxResult = "NOT
checked";
if (check.isChecked())
checkBoxResult = "checked";
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor
editor = settings.edit();
editor.putString("noshow",
checkBoxResult);
// Commit the edits!
// sunnovalthesis();
editor.commit();
return;
} });
adb.setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int which) {
String checkBoxResult = "NOT
checked";
if (check.isChecked())
checkBoxResult = "checked";
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor =
settings.edit();
editor.putString("noshow",
checkBoxResult);
// Commit the edits!
// sunnovalthesis();
editor.commit();
return;
} });
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
String noshow = settings.getString
("noshow", "NOT checked");
if (noshow != "checked" ) adb.show();