문제

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.

도움이 되었습니까?

해결책

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();
        }

});

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top