Reputation: 420
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.
Upvotes: 1
Views: 2628
Reputation: 4122
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();
}
});
Upvotes: 3