私はアンドロイドアプリを書いています。ボタンがあり、クリックすると警告ダイアログが表示されます。このダイアログには 12 個のチェック ボックスがあります。私の問題は、すべてのチェックボックスが重なっているということです。私の活動は:
public class Get_CheckboxActivity extends Activity {
private String result="";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_report);
View checkBoxView = View.inflate(this, R.layout.checkbox, null);
final CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
final CheckBox checkBox1 = (CheckBox) checkBoxView.findViewById(R.id.checkbox1);
final CheckBox checkBox2 = (CheckBox) checkBoxView.findViewById(R.id.checkbox2);
final CheckBox checkBox3 = (CheckBox) checkBoxView.findViewById(R.id.checkbox3);
final CheckBox checkBox4 = (CheckBox) checkBoxView.findViewById(R.id.checkbox4);
final CheckBox checkBox5 = (CheckBox) checkBoxView.findViewById(R.id.checkbox5);
final CheckBox checkBox6 = (CheckBox) checkBoxView.findViewById(R.id.checkbox6);
final CheckBox checkBox7 = (CheckBox) checkBoxView.findViewById(R.id.checkbox7);
final CheckBox checkBox8 = (CheckBox) checkBoxView.findViewById(R.id.checkbox8);
final CheckBox checkBox9 = (CheckBox) checkBoxView.findViewById(R.id.checkbox9);
final CheckBox checkBox10 = (CheckBox) checkBoxView.findViewById(R.id.checkbox10);
final CheckBox checkBox11 = (CheckBox) checkBoxView.findViewById(R.id.checkbox11);
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox.getText().toString());
}
});
checkBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox1.getText().toString());
}
});
checkBox2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox2.getText().toString());
}
});
checkBox3.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox3.getText().toString());
}
});
checkBox4.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox4.getText().toString());
}
});
checkBox5.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox5.getText().toString());
}
});
checkBox6.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox6.getText().toString());
}
});
checkBox7.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox7.getText().toString());
}
});
checkBox8.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox8.getText().toString());
}
});
checkBox9.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox9.getText().toString());
}
});
checkBox10.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox10.getText().toString());
}
});
checkBox11.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
result=result.concat(checkBox11.getText().toString());
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("title")
.setView(checkBoxView)
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent (Get_CheckboxActivity.this,Add_ReportActivity.class);
// intent.putExtra("ckeck_res",result );
startActivity(intent); }
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
}).show();
}
}
およびcheckbox.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<CheckBox
android:id="@+id/checkbox"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="c12"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox1"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c11"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox2"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c10"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox3"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c9"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox4"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c8"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox5"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c7"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox6"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c6"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox7"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c5"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox8"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c4"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox9"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c3"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox10"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c2"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<CheckBox
android:id="@+id/checkbox11"
style="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:text="c1"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
</FrameLayout>
scrollviewを使ったら止まった!何か方法はありますか?