I have a spinner and when the user selects I want to call another java class using new Intent. The code below worked when I was using a Button but now I have it attached to the Spinner select I think it has something to do with view.getContext();
areaspinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
int item = areaspinner.getSelectedItemPosition();
Intent myIntent = new Intent(view.getContext(), ShowXMLPAR.class);
startActivityForResult(myIntent, 0);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Can anyone help me update this part of the code.
you are right rather then view.getContext(0 you need reference to your Activity that has this spinner
example
Intent myIntent = new Intent(MyActivity,this, ShowXMLPAR.class);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.