Bir misafir check in yaparken check-in yapıyorum. Kullanıcının check-in sırasında girmesi gereken bilgileri içeren onay kutularının bulunduğu bir alan sayfası istiyorum. Örneğin: misafir adı, misafir telefon numarası, imza vb. etkinlik, her onay kutusu seçildiğinde görünür hale gelen düzenleme metinleri olan yeni bir etkinlik hakkında misafir bilgileri girebilmek istiyorum. Ben setOnCheckedChangeListener kullanmayı denedim ama android uygulama geliştirme için yeni ve çalışmasını göremiyorum. Kodu doğru etkinlik xml dosyasına koyarsam bile emin değilim. Sağladığınız herhangi bir yardım harika olurdu! İşte Android: Bir etkinlikteki onay kutusu tıklandığında, başka bir etkinlikte düzenleme metni düzenleyin görünür
(benim ana faaliyeti isnt) benim guest.java kod İştepackage com.example.gena.ng;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
public class Guest extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
CheckBox checkBox;
EditText editText1 = (EditText) findViewById(R.id.editText1);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guest);
checkBox = (CheckBox) findViewById(R.id.checkBox);
checkBox.setOnCheckedChangeListener(this);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.checkBox:
if (isChecked == true) {
editText1.setVisibility(View.VISIBLE);
} else {
editText1.setVisibility(View.GONE);
}
break;
}
}
}
burada activity_guest.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.genagizzi.ng.Guest">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:visibility="gone"
android:text="Guest Name"
android:ems="10"
android:id="@+id/editText1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
Ve benim activity_fields.xml olduğunu
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.genagizzi.ng.fields"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Please select the fields you would like to be displayed and press done."
android:id="@+id/textView"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:onClick="listOptionsCheck"
android:text="Done"/>
</LinearLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Here you put the rest of your current view-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Guest Name"
android:id="@+id/checkBox"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Drop Off Contact Name"
android:id="@+id/checkBox2"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Drop Off Contact Phone Number"
android:id="@+id/checkBox3"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time Checked In"
android:id="@+id/checkBox4"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Signature Box"
android:id="@+id/checkBox5"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check In/Out Button"
android:id="@+id/checkBox6"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pick Up Contact Name"
android:id="@+id/checkBox7"
android:checked="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pick Up Contact Phone Number"
android:id="@+id/checkBox8"
android:checked="false"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Bunun nasıl uygulanacağından emin değilim, java programlamada yeni başlayan biriyim. Bu yüzden alanlarımda, onay kutularındaki sınıf, onay kutusunun değerini saklamak için ilk kodu içeren kayıtlı Kayıtlar adlı bir yöntem içerir. Fakat onay kutusunun değeri nasıl saklanır?Onay kutusunu xml düzenindeki kimliğe nereye atacağım, böylece hangi onay kutusunu saklayacağını biliyor mu? – Gena