我正在开发一个 android 应用程序,其中问卷活动包含每个问题的单选按钮。我设计了线性布局的活动。所以现在我想检查用户是否回答了所有问题。我面临的问题在公共无效 OnClick(View v) 帮助我修改 java 代码。
<RadioGroup
android:id="@+id/Mquestion1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_1_rb1" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_1_rb2" />
<RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_1_rb3" />
</RadioGroup>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_2_view"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RadioGroup
android:id="@+id/Mquestion2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_2_rb1" />
<RadioButton
android:id="@+id/radioButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_2_rb2" />
<RadioButton
android:id="@+id/radioButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_2_rb3" />
</RadioGroup>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_3_view"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RadioGroup
android:id="@+id/Mquestion3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioButton7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MQ1_3_rb1" />
<RadioButton
android:id="@+id/radioButton8" …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个 Android 应用程序,其中登录活动有 editText、RadioButton、Spinner 和一个按钮。因此,当按下按钮时,我必须通过检查是否填写了所有字段来验证我的表单,否则会向用户。任何人都可以帮我解决java代码吗?提前致谢。
public void OnClickListener(View v)
{
name=(EditText)findViewById(R.id.editText1);
years1=(RadioButton)findViewById(R.id.radioButton3);
years2=(RadioButton)findViewById(R.id.radioButton4);
years3=(RadioButton)findViewById(R.id.radioButton5);
manager=(RadioButton)findViewById(R.id.radioButton1);
teamleader=(RadioButton)findViewById(R.id.radioButton2);
rg1=(RadioGroup)findViewById(R.id.Designation);
rg2=(RadioGroup)findViewById(R.id.Years);
Button proceed = (Button) findViewById(R.id.button1);
proceed.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if (validationSuccess())
{
}
else if(manager.isChecked())
{
Intent managerIntent = new Intent(getApplicationContext(), ManagerQuestionnaire1.class); // <----- START "SEARCH" ACTIVITY
startActivityForResult(managerIntent, 0);
}
else if(teamleader.isChecked())
{
Intent teamleaderIntent = new Intent(getApplicationContext(), TeamleaderQuestionnaire1.class); // <----- START "TYPE ENTRIES OUT" ACTIVITY
startActivityForResult(teamleaderIntent, 0);
}
else {
AlertDialog();
}
}
});
}
private …
Run Code Online (Sandbox Code Playgroud) validation android buttonclick android-spinner onclicklistener