Note that there are some explanatory texts on larger screens.

plurals
  1. POTransfer data between activity with spinners
    text
    copied!<p>i am new in Android development.</p> <p>Im trying to transfer selected data from multiple spinners (Search activity) to another activity (JSON Search result activity)</p> <p>and at the end i have button that open the search result</p> <p>Search activity: i have the java spinner</p> <pre><code>ArrayAdapter&lt;CharSequence&gt; whatlist = ArrayAdapter.createFromResource(this, R.array.whatlist, android.R.layout.simple_spinner_item); whatlist.setDropDownViewResource(R.layout.spinner_style); spwhat = (Spinner) findViewById(R.id.spWhat); spwhat.setAdapter(whatlist); spwhat.setOnItemSelectedListener(new MyOnItemSelectedListener()); </code></pre> <p>and the MyOnItemSelectedListener</p> <pre><code> public class MyOnItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) { strs = new Bundle(); Intent i = new Intent(SearchActivity.this, SearchResult.class); strs.putString("setwhat", parent.getItemAtPosition(pos).toString()); i.putExtras(strs); } public void onNothingSelected(AdapterView&lt;?&gt; arg0) {} } </code></pre> <p>This is the button</p> <pre><code>btnsearch = (Button)findViewById(R.id.btnSearch); btnsearch.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent ia = new Intent(SearchActivity.this, SearchResult.class); SearchActivity.this.startActivity(ia); } }); </code></pre> <p>This is in the search result</p> <pre><code> Bundle extras = getIntent().getExtras(); if(extras!=null){ Integer item = extras.getInt("setwhat"); //Use a switch(item) here to switch to different links based on selection TextView tv = (TextView) findViewById(R.id.tvtv); tv.setText("Another Activity, Item is :" + item.toString()); </code></pre> <p>the text wont change. i have tried any tutorial on the web and searching here for a solution for hours.. anyone can help?</p>
 

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