Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think there is some problem in your layout file. </p> <p>I have edited the code and created main.xml and changed EditText ids from 1text,2text,3text,4text to text1,text2,text3,text4 </p> <p>The code given bellow is working.</p> <p><strong>Following is the code for activity</strong></p> <pre><code> public TextWatcher last; public TextWatcher _list1; public TextWatcher _list2; public EditText active; public RadioButton checked; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final EditText t1 = (EditText) findViewById(R.id.text1); final EditText t2 = (EditText) findViewById(R.id.text2); final EditText t3 = (EditText) findViewById(R.id.text3); final EditText t4 = (EditText) findViewById(R.id.text4); final Context c = getApplicationContext(); final RadioGroup g1 = (RadioGroup) findViewById(R.id.radioGroup1); g1.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { checked = (RadioButton) g1.findViewById(g1.getCheckedRadioButtonId()); if (((String) checked.getText()).equalsIgnoreCase("But1")) { active.removeTextChangedListener(last); active = t1; active.setText(""); active.addTextChangedListener(_list1); last = _list1; } else if (((String) checked.getText()).equalsIgnoreCase("But2")) { active.removeTextChangedListener(last); active = t2; active.setText(""); active.addTextChangedListener(_list2); last = _list2; } else if (((String) checked.getText()).equalsIgnoreCase("But3")) { active = t3; } else if (((String) checked.getText()).equalsIgnoreCase("But4")) { active = t4; } } }); checked = (RadioButton) g1.findViewById(g1.getCheckedRadioButtonId()); active = t1; active.setText(""); _list1 = (new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { Toast.makeText(c, "onTextChanged called(_list1 watcher)", Toast.LENGTH_SHORT).show(); } }); _list2 = (new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { Toast.makeText(c, "onTextChanged called(_list2 watcher)", Toast.LENGTH_SHORT).show(); } }); active.addTextChangedListener(_list1); last = _list1; } } </code></pre> <p><br> <strong>Following is the code for main.xml file</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;RadioGroup android:id="@+id/radioGroup1" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;RadioButton android:id="@+id/But1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="But1" /&gt; &lt;EditText android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /&gt; &lt;RadioButton android:id="@+id/But2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="But2" /&gt; &lt;EditText android:id="@+id/text2" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /&gt; &lt;RadioButton android:id="@+id/But3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="But3" /&gt; &lt;EditText android:id="@+id/text3" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /&gt; &lt;RadioButton android:id="@+id/But4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="But4" /&gt; &lt;EditText android:id="@+id/text4" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" &gt; &lt;/EditText&gt; &lt;/RadioGroup&gt; &lt;/LinearLayout&gt; </code></pre> <p>Try this. Its working.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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