Friends I have 2 fragment- (a) on which there is a spinner and there is a toolbar on which there is an item (the icon is in the form of png). I need that when you select one of the fields spiner- (a) I have changed the item (icon) in the toolbar. I can not understand where in general it is necessary to do implementation, pliz tell me!
1 answer
The following lesson can help: StartAndroid. Lesson 56. Spinner - drop-down list.
// устанавливаем обработчик нажатия spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // показываем позицию нажатого элемента Toast.makeText(getBaseContext(), "Position = " + position, Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); Only instead of Toast.makeText, call the icon change.
|
Toolbaritems if it is assigned asActionBardone inonPrepareOptionsMenu()- pavlofff