android - Link fragment button to another activity -
below edited code
@override public void onclick(view v) { switch (v.getid()){ case r.id.btn_chg_password: showdialog(); break; case r.id.btn_order: changemenu(); break; } } private void changemenu() { sharedpreferences.editor editor = pref.edit(); editor.putboolean(constants.is_logged_in,false); editor.putstring(constants.email,""); editor.putstring(constants.name,""); editor.putstring(constants.unique_id,""); editor.apply(); order(); } private void order(){ fragment login = new loginfragment(); fragmenttransaction ft = getfragmentmanager().begintransaction(); ft.replace(r.id.activity_activityresult1,activityresult1); ft.commit();
i want change link activity_activityresult1 after press btn_order believe cannot link because fragment activity? on clicking btn_order want direct activity_activityresult1 <----- layout
below original code
@override public void onclick(view v) { switch (v.getid()){ case r.id.btn_chg_password: showdialog(); break; case r.id.btn_logout: logout(); break; } } private void logout() { sharedpreferences.editor editor = pref.edit(); editor.putboolean(constants.is_logged_in,false); editor.putstring(constants.email,""); editor.putstring(constants.name,""); editor.putstring(constants.unique_id,""); editor.apply(); gotologin(); } private void gotologin(){ fragment login = new loginfragment(); fragmenttransaction ft = getfragmentmanager().begintransaction(); ft.replace(r.id.fragment_frame,login); ft.commit(); }
private void order(){ intent mintent = new intent(); mintent.setclassname(your_package_name_string, your_activity_name_string); // ex: package name can "com.example" // activity name "com.example.contact_developer" startactivity(myintent); or intent myintent = new intent(getactivity(), targetactivity.class); startactivity(myintent); }
use if mean navigate activity order button click of fragment hope helps.
Comments
Post a Comment