+ 2
Could anyone help me to work with spinner and textview in Android studio
I had one spinner and i have some dropdown elements in that. and i need to fetch some data from resources file then i have to display it in textview accounting to the Id of the spinner
3 Respuestas
+ 4
The below code helps in filling the selected spinner item in the textview.
TextView textView = (TextView) findViewById(R.id.textView);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Add items to your spinner here (From what I understand, you already did this).
// Add OnItemSelectedListener to listen spinner item selections.
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView adapter, View v, int i, long lng) {
String selecteditem = adapter.getItemAtPosition(i).toString();
textView.setText(selecteditem);
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
}
});
+ 3
getApplicationContext().getString(R.string.text1); can be used to access a string named 'text1' in strings.xml
+ 2
it shows only the content which were stored in spinner .. but i have to fetch the resource from the XML file which is stored in the src/main/red/value/string.xml