Hi guys
Please can anyone help me with this problem. I'm building a app whereby
questions is answered to questions via 3 radiobuttons per questions
(grouped per question).
My problem is that I dont receive back a message from the Toast. Can
anyone please tell me where I make the mistake as I cannot continue with
the development before this is sorted.
Here is my code:
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast;
public class Layout1 extends Fragment {
RadioGroup radioGroup;
RadioButton q1t, q1f, q1na, q2t, q2f, q2na;
EditText c1, c2, c3, c4, c5, c6, c7, c8;
Button cnt1;
private double value = 0;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.layout1, container, false);
radioGroup = (RadioGroup)v.findViewById(R.id.rgQ1);
radioGroup = (RadioGroup)v.findViewById(R.id.rgQ2);
q1t= (RadioButton)v.findViewById(R.id.q1t);
q1f= (RadioButton)v.findViewById(R.id.q1f);
q1na= (RadioButton)v.findViewById(R.id.q1na);
q2t= (RadioButton)v.findViewById(R.id.q2t);
q2f= (RadioButton)v.findViewById(R.id.q2f);
q2na= (RadioButton)v.findViewById(R.id.q2na);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
switch (v.getId()) {
case R.id.rgQ1:
if (q1t.isChecked() == true) {
value = 1;
Toast.makeText(getActivity(), "Compliant",
Toast.LENGTH_SHORT).show();
} else if (q1f.isChecked() == true) {
value = 0;
Toast.makeText(getActivity(), "Not Compliant",
Toast.LENGTH_SHORT).show();
} else {
q1na.isChecked();
value = -1;
Toast.makeText(getActivity(), "Not Applicable",
Toast.LENGTH_SHORT).show();
}
break;
case R.id.rgQ2:
if (q2t.isChecked() == true) {
value = 1;
Toast.makeText(getActivity(), "Compliant",
Toast.LENGTH_SHORT).show();
} else {
if (q2f.isChecked() == true) {
value = 0;
Toast.makeText(getActivity(), "Not Compliant",
Toast.LENGTH_SHORT).show();
} else {
q2na.isChecked();
value = -1;
Toast.makeText(getActivity(), "Not Applicable",
Toast.LENGTH_SHORT).show();
}
break;
}
}
}
});
return v;
}
}
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/0b4b291e-ec08-4786-bcc7-c512adc9e9ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.