1. Check out our companion app, Forums for Android! Download from Google Play

Spinner choice

Discussion in 'Application Development' started by ConnorCZ, Jul 4, 2012.

  1. ConnorCZ

    ConnorCZ New Member
    Thread Starter
    5

    Jul 4, 2012
    1
    0
    5
    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
    15

    Jun 20, 2011
    31
    0
    15
    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...