1

I have a spinner which is already made and working, what i need to do is "know" when the user clicks on the spinner to choose an item (when its expanded) and when the user clicks on an item inside the spinner (whatever that item is).

I'm asking this because i need to un-display two EditText box on first click and then after he/she choose an item i will redisplay them.

any help is appreciated! thank you

public class MyAdapter extends ArrayAdapter<String>
{
    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/hatten.ttf");

    public MyAdapter(Context context, int textViewResourceId,   String[] objects) {
        super(context, textViewResourceId, objects);
    }

    @Override
    public View getDropDownView(int position, View convertView,ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    public View getCustomView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater =getLayoutInflater();
        View test=inflater.inflate(R.layout.row, parent, false);
        TextView label=(TextView)test.findViewById(R.id.company);
        label.setText(beverage[position]);
        label.setTypeface(font);

        return test;
    }
}
JamesAnd
  • 410
  • 1
  • 8
  • 28

2 Answers2

1

you can verify of the spinner state with:

if(yourSpinner.isShown()){
   editText.setVisibility(View.VISIBLE);
}
else{
    editText.setVisibility(View.GONE)
} 
1

You need to use "OnSpinnerEventsListener". There is a more detailed answer https://stackoverflow.com/a/18636385/2391145

Community
  • 1
  • 1
Alex T.
  • 29
  • 4
  • thanks alex! thats actually what i need, but i am unable to implement it! where can i add the action that should take place in case opened or in case its closed? thanks – JamesAnd May 12 '15 at 22:12