Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Spinner listener in Android?
    primarykey
    data
    text
    <p>As I am working on getting a custom spinner and displaying the value in toast. The values are setting to the spinner correctly but I am unable to display them in toast. My code is</p> <p>Main.java</p> <pre><code>public class Main extends Activity { ArrayList&lt;String&gt; ast = new ArrayList&lt;String&gt;(); Spinner customspinner; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); customspinner = (Spinner)findViewById(R.id.spinner1); ast.add("111111"); ast.add("222222"); ast.add("333333"); ast.add("444444"); MyAdapter adp = new MyAdapter(); customspinner.setAdapter(adp); System.out.println(ast); customspinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; adapter, View v, int position, long val) { // TODO Auto-generated method stub //here when spinner was selected I need to save those two custom textviews in two string and need to display them in toast.... //String getspineer = customspinner.getSelectedItem().toString(); //Toast.makeText(getApplicationContext(), "spinner --- " + getspineer , Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // TODO Auto-generated method stub } }); } public class MyAdapter extends BaseAdapter{ @Override public int getCount() { // TODO Auto-generated method stub return ast.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View v = null; LayoutInflater inflater = getLayoutInflater(); v = inflater.inflate(R.layout.customspinner, null); TextView tv = (TextView)v.findViewById(R.id.textView1); TextView tv1 = (TextView)v.findViewById(R.id.textView2); String arlstdate[] = ast.get(position).split("~"); for (int i = 0; i &lt; arlstdate.length; i++) { tv.setText(arlstdate[i]); tv1.setText(arlstdate[i]); } return v; } } </code></pre> <p>}</p> <p>Here what I am looking for is, when I select spinner, I need to save the following two textview values in two string and need to display them in Toast mess seperately.</p> <p>Can anyone help me with this. After a lot of search I found this code but unable to save to text values in string &amp; display..</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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