Note that there are some explanatory texts on larger screens.

plurals
  1. POselector not worked first time onclick in android
    primarykey
    data
    text
    <p>I have four radio buttons which are options of question.<br/> I have to apply onclick listener here.<br/> I want if user click on right answer background use first selector and if select wrong answer second selector work and the radio button which have right answer also show its pressed event I have to set selector on run time.<br/>And I have single page for multiple question.problem is selector not worked fine while i click on first time on radio button.and second time it works fine.but with wrong answer how could i call oppressed of right answer radio button.</p> <p>This is my selector code:-</p> <pre><code> &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/brown" /&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/green" /&gt; &lt;item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/green" /&gt; &lt;/selector&gt; </code></pre> <p>code of one radio button but i have four case for four radiobutton like this:-</p> <pre><code> case R.id.radio0: clickSound(); if (radio0.isChecked()) { user_ans = radio0.getText().toString().trim(); if (correct_answer.equalsIgnoreCase(user_ans)) { radio0.setBackgroundResource(R.drawable.green_selector_brown); ern_score += 1000; score.setText(String.valueOf(ern_score)); } else { radio0.setBackgroundResource(R.drawable.red_selector_brown); } ++ctr; } break; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload