android - How can i pass adapter to fragment like in intent -
i new android , trying call mapfragment
adapter after on click using intent below code
below adapter code:
public view getview(int position, @nullable view convertview, @nonnull viewgroup parent) { final businfo info = getitem(position); view view = layoutinflater.from(context).inflate(r.layout.bus_only_list,null); textview busname; busname = (textview) view.findviewbyid(r.id.busname); busname.settext(info.name); view.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { pref = context.getsharedpreferences("businfo",context.mode_private); sharedpreferences.editor editor = pref.edit(); editor.putstring("bus_name",info.name); editor.commit(); intent intent = new intent(context, mapsfragment.class); intent.putextra("name",info.name); context.startactivity(intent);> } }); return view; }
i want pass mapfragment using intent redirect mainactivity
instead of mapfragment
. how can stop transferring mainactivity?
thank you.
as guys mentioned before: 1. use callback or casting on context (your activity must handle changing fragments itself). 2. change fragments use activity's fragmentmanager - intent used start activity.
wiki
Comments
Post a Comment