Reputation: 73
In my task, I have two spinners and one textView. I choose a city from the first spinner than, I choose a person from the second spinner. On textView, I want to display some information according to the selected person in the spinner. In my program, person and textView parts are populating from JSON. My problem is that on my textView I can see only information about the first item of the spinner. When I select another person, textView does not update.
textView = (TextView)findViewById(R.id.textView23);
cenazeSpinner.setAdapter(new ArrayAdapter<String>(Celenk1.this,
android.R.layout.simple_spinner_dropdown_item,
cenazeList));
cenazeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> adapterView,View view, int position,long l){
textView.setText("Cenaze Töreni Tarihi: "+celenkList.get(position).getCenazeToreniTarihi()+ "\n"+"Cenaze Töreni Vakti: "+celenkList.get(position).getCenazeToreniVakti());
}
I tried to write update function under the class, however, it does not work.
Upvotes: 0
Views: 236
Reputation: 785
From what I can understand your comments, spinner actually works fine, but you have problems with setting the textView. Below are some possible debugging attempts and possible explanations:
Are you sure textView is the TextView you want? What happens when you put textView.setText("" + position); inside the spinner does the textView change?
If the textview doesn't change, either the textView you are looking is not the same one you are referencing, or another piece of code is changing textView constantly.
If it does, then most probably the problem is with the celenklist. If you print the information in the celenklist to logs, are the logs different when different people are selected? Are we sure we are getting different data (compared to the default one)? Maybe we are selecting different items at celenklist but because the data is same, we cannot see it.
Upvotes: 1