Spinner choice


Last Updated:

  1. ConnorCZ

    ConnorCZ New Member This Topic's Starter

    Joined:
    Jul 4, 2012
    Messages:
    1
    Likes Received:
    0
    Hi guys,

    I want to create an app, but I have first little problem.

    I have a Spinner and TextView and some strings in resources. And I want to make, when I choose some item from Spinner, for example, Czech Republic, I want to appear in TextView "Capital City: Prague".

    Any idea how to do that? Thanks a lot :)
     

    Advertisement
  2. tneva82

    tneva82 Active Member

    Joined:
    Jun 20, 2011
    Messages:
    31
    Likes Received:
    0
    Pretty sure it goes by attaching something like following to spinners onChange event. The pos is selected item(from 0 onward).

    public class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
    View view, int pos, long id) {
    // here alter the textview
    }

    public void onNothingSelected(AdapterView parent) {
    // Do nothing.
    }
    }
     

Share This Page

Loading...