Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid : ignore conditional array adaptor for spinner
    primarykey
    data
    text
    <p>I am new to Android. I tried to form a conditional adaptor (depends on a String variable) for different string arrays.</p> <pre><code> TextView textPrompt; textPrompt = (TextView)findViewById(R.id.textprompt); final String acType = i.getStringExtra("type"); textPrompt.setText(acType); if (acType == "400G"){ spinnerSurface = (Spinner) findViewById(R.id.spinnerSurface); ArrayAdapter&lt;CharSequence&gt; adapterSurface = ArrayAdapter.createFromResource( this, R.array.surface_option_1, android.R.layout.simple_spinner_item); adapterSurface.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerSurface.setAdapter(adapterSurface); } else if (acType != "400G"){ spinnerSurface = (Spinner) findViewById(R.id.spinnerSurface); ArrayAdapter&lt;CharSequence&gt; adapterSurface = ArrayAdapter.createFromResource( this, R.array.surface_option, android.R.layout.simple_spinner_item); adapterSurface.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerSurface.setAdapter(adapterSurface); } spinnerSurface.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) { TextView tx = (TextView)v; Log.i("\n\nid",String.valueOf(tx.getText())); } public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // TODO Auto-generated method stub } }); </code></pre> <p>I use a textPrompt to check value of acType. No matter acType is "400G" or not "400G", program will take acType as not "400G" thus R.array.surface_option is taken instead of R.array.surface_option1. Please help.</p>
    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.
    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