Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging TextView value with change in selectedItem on Spinner
    primarykey
    data
    text
    <p>I am totally at my wits end with trying to change the value of a TextView based on what is selected in the adjoining Spinner.</p> <pre><code>public class SpinnerSelectItemListener implements OnItemSelectedListener { private Context context; public SpinnerSelectItemListener(Context c){ this.context = c; } public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) { View view = null; TextView textView = null; LayoutInflater inflater = LayoutInflater.from(context); parent.getItemAtPosition(position); view = new View(context); view = inflater.inflate(R.layout.common_app_header, null); textView = (TextView)view.findViewById(R.id.customer_name_value); textView.setText("John"); } public void onNothingSelected(AdapterView&lt;?&gt; parent) { // TODO Auto-generated method stub } } </code></pre> <p>When I run this is debug mode everything is happening as expected but when all is done, the value of the textView doesn't change on the emulator even when the debugger is showing the new value. There is definitely something really silly that I am missing. Please help.</p> <p>EDIT: The situation is something like I selected the id number of an employee from the spinner and depending on the selection, the TextView displaying the employee's name changes. The TextView I want to modify is outside the spinner. </p> <p>EDIT2: This runs fine when I define the listener inline i.e. I write something like</p> <pre><code>modelspinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) { TextView textView = null; textView = (TextView)findViewById(R.id.customer_segment_value); textView.setText("Commercial"); textView = (TextView)findViewById(R.id.TIV_value); textView.setText(R.string.app1_name); } public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // TODO Auto-generated method stub } }); </code></pre> <p>Can someone explain what is wrong with the code that I had written earlier.</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. 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