9
क्या रेडियोबटन को चेक किए गए रेडियोबटन पर क्लिक करके रेडियोबटन को अनचेक करने का कोई संभावित तरीका है?रेडियोबटन की अनचेकिंग - वैकल्पिक विधि
क्या रेडियोबटन को चेक किए गए रेडियोबटन पर क्लिक करके रेडियोबटन को अनचेक करने का कोई संभावित तरीका है?रेडियोबटन की अनचेकिंग - वैकल्पिक विधि
RadioGroup radioGroup;
RadioButton radioButton1;
RadioButton radioButton2;
RadioButton radioButton3;
boolean hack = false;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
radioGroup = (RadioGroup) findViewById(R.id.rg);
radioButton1 = (RadioButton) findViewById(R.id.r1);
radioButton2 = (RadioButton) findViewById(R.id.r2);
radioButton3 = (RadioButton) findViewById(R.id.r3);
OnClickListener radioClickListener = new OnClickListener()
{
public void onClick(View v)
{
if (v.getId() == radioGroup.getCheckedRadioButtonId() && hack)
{
radioGroup.clearCheck();
}
else
{
hack = true;
}
}
};
OnCheckedChangeListener radioCheckChangeListener = new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
hack = false;
}
};
radioButton1.setOnCheckedChangeListener(radioCheckChangeListener);
radioButton2.setOnCheckedChangeListener(radioCheckChangeListener);
radioButton3.setOnCheckedChangeListener(radioCheckChangeListener);
radioButton1.setOnClickListener(radioClickListener);
radioButton2.setOnClickListener(radioClickListener);
radioButton3.setOnClickListener(radioClickListener);
}
ठीक है अब मैंने इसे अपडेट किया है। यह फिलिप
ठीक है, बीमार बाद में परीक्षण करें, वास्तव में आपके उत्तर की सराहना करें, धन्यवाद! –
अरे आदमी, यह कभी भी रेडियोबटन की जांच नहीं करता है, क्योंकि यह जांच रहा है और उसके बाद अनचेकिंग के बाद, अंतिम स्थिति अनचेक की गई है! :/ –
हां फिलिप का परीक्षण किया गया है और आपको यह बताया गया है। हालांकि मैं इसे एक बुलियन की मदद से काम करने में कामयाब रहा .. कुछ क्षणों में जवाब अपडेट कर दूंगा। – Varun