Question

I have a Spinner that is filled with an ArrayAdapter, the ViewHolder in this array Adapter has two TextView, those are: textViewName, textViewId ( the id textView is hidden ), how can I acess this textView to get their text? I have no ideia, everything is ok, but I don't know how to acess those textView to get their text. I want to get this text after a button has been pressed. Any material I would appreciate, thank you.

Était-ce utile?

La solution

Well you can get the text from the view parameter which passed in onItemSelected like the code below :

      spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parentView, View v, int position, long id) {


            // Get selected row data to show on screen
            String Company    = ((TextView) v.findViewById(R.id.company)).getText().toString();
            String CompanyUrl = ((TextView) v.findViewById(R.id.sub)).getText().toString();
        }

});

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top