i'm new with android studio and does not really expert with programming. hope to get some help. now i'm developing a health application where user can click on the 2d image for their symptoms the 2d image with button at specific part from this image checkbox will appear if user click on any parts of the button, like this checkbox in dialog box appear when user click on button at the 2d image and this enter image description here , i have a lot of problem regarding this, the first is, when tick at the checkbox the tick disappear the moment i click on other body part(other button on the 2d image). means that the dialog box not save the checkbox status when tick. next, how do i pass the checkbox data to another activity because i create all the checkbox in different activities then i put code so that the checkbox will appear in dialog box. i have to pass the checkbox data into one other activity because i need to create rule based condition regarding the symptom for the diagnosed result
activity_checkbox_neck.xml(list checkbox of symptom in neck)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".CheckboxNeckActivity">
<TextView
android:id="@+id/TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please select the best one"
android:textSize="18sp"/>
<TextView
android:id="@+id/TV1"
android:layout_below="@id/TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Where does the pain / discomfort spread"
android:textSize="18sp"/>
<CheckBox
android:id="@+id/CNeck1"
android:layout_below="@+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Throat/Neck" />
<CheckBox
android:id="@+id/CNeck2"
android:layout_below="@+id/CNeck1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jaw" />
<CheckBox
android:id="@+id/CNeck3"
android:layout_below="@+id/CNeck2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back of head and neck" />
<CheckBox
android:id="@+id/None"
android:layout_below="@+id/CNeck3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None of the above" />
<LinearLayout
android:layout_below="@+id/None"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<Button
android:id="@+id/save"
android:layout_width="150dp"
android:layout_height="45dp"
android:text="SAVE"
android:layout_weight="1" />
<Button
android:id="@+id/cancel"
android:layout_width="150dp"
android:layout_height="45dp"
android:text="CANCEL"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
activity_checkbox_arm.xml(list checkbox of symptom in arm)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".CheckboxArmActivity">
<TextView
android:id="@+id/TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please select the best one"
android:textSize="18sp"/>
<TextView
android:id="@+id/TV1"
android:layout_below="@id/TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Where does the pain / discomfort spread"
android:textSize="18sp"/>
<CheckBox
android:id="@+id/leftArm"
android:layout_below="@+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left arm" />
<CheckBox
android:id="@+id/bothArms"
android:layout_below="@+id/leftArm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Both arms" />
<CheckBox
android:id="@+id/None"
android:layout_below="@+id/bothArms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None of the above" />
<LinearLayout
android:layout_below="@+id/None"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<Button
android:id="@+id/save"
android:layout_width="150dp"
android:layout_height="45dp"
android:text="SAVE"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
TwoDActivity1.java(checkbox appear in the dialog box in this activity)
private Button head;
private Button neck;
private Button shoulder;
private Button chest;
private Button abdominal;
private Button arm;
private Button pulse;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two_d1);
head = (Button) findViewById(R.id.head);
neck = (Button) findViewById(R.id.neck);
shoulder = (Button) findViewById(R.id.shoulder);
chest = (Button) findViewById(R.id.chest);
abdominal = (Button) findViewById(R.id.abdominal);
arm = (Button) findViewById(R.id.arm);
pulse = (Button) findViewById(R.id.pulse);
head.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog();
}
});
neck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog1();
}
});
shoulder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog2();
}
});
chest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog3();
}
});
arm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog4();
}
});
pulse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog5();
}
});
abdominal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showUpdateDialog6();
}
});
}
private void showUpdateDialog() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_head, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog1() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_neck, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog2() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_shoulder, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog3() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_chest, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog4() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_arm, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog5() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_pulse, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
private void showUpdateDialog6() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.activity_checkbox_abdominal, null);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
so how do i pass the checkbox data checked to this TwoDActivity1.class n retrieve so that i can make rule condition when user tick on checkbox
Aucun commentaire:
Enregistrer un commentaire