I saw this post Spinner : onItemSelected not called when selected item remains the same that may able to solve my problem. but i have problem to use it in my code. may i know how does it works?
I created a class for the spinner and changed the xml file .. it doesn't crash but it still doens't function the way i want. what i want it to function is the onitemselected function even when i select the same item
Part of my code for Main class and others
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gestureDetector = new GestureDetector(this,new SwipeGestureDetector());
MySpinner toList = (MySpinner) findViewById(R.id.toList);
dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, new ArrayList<String>());
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
toList.setAdapter(dataAdapter);
toList.setOnItemSelectedListener(listener);
........
public class CustomOnItemSelectedListener implements OnItemSelectedListener //Function when the dropdown menu item is choosen
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos,long id)
{
0 comments:
Post a Comment