안드로이드 개발 질문/답변
(글 수 45,052)
checkbox 를 클릭하면 더이상 앱이 다시실행될때 dialog 가 안나오게 하려는데요
여기 소스코드가있습니다.
<MainActivity.java>
dialog 부분만 잘랐습니다.
@Override
protected void onStart()
{
super.onStart();
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog);
dialog.setTitle("Warning!");
Button button = (Button) dialog.findViewById(R.id.okay);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}<dialog.xml>
layout 부분입니다.
<?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>어떻게 해야할까요 도움좀 부탁드리겠습니다 ^^;;




preference로 값을 저장했다가 해당 값이 저장 되어 있으면 다이얼로그를 생성하지 않는 방법으로 하면 어떨까 합니다.
실제 구현은 조금만 찾아보시면 쉽게 하실 수 있으실 것 같습니다.