android - Spinner Intent Activity Change -
i've been trying spinner logic change activities on selection change, code below reason isn't changing. log.d returns correct selection, know itemselect triggering, not sure why intent not changing.
public class listownersactivity extends activity implements onitemclicklistener, onclicklistener { spinner spinner; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_list_cars); spinner = (spinner) findviewbyid(r.id.spinner3); arrayadapter adapter= arrayadapter.createfromresource(this,r.array.domain,android.r.layout.simple_spinner_item); adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); spinner.setadapter(adapter); addlistener(); } public void addlistener() { spinner.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> arg0, view view, int position, long row_id) { if (arg0.getitematposition(position).tostring().equals("ownerslist")) { log.d("position", "position: " + position); intent y = new intent(getapplicationcontext(), listownersactivity.class); startactivity(y); } if (arg0.getitematposition(position).tostring().equals("carlist")) { log.d("position", "position: " + position); intent x = new intent(getapplicationcontext(), listcarsactivity.class); startactivity(x); } } @override public void onnothingselected(adapterview<?> arg0) { // todo auto-generated method stub } }); }
}
i not sure mean 'intent not changing'. can try changing second if else if.
Comments
Post a Comment