Thursday 15 September 2011

add fragment to popup window in android -



add fragment to popup window in android -

my problem want add together fragment pop window display info when list clicked. list contains custom adapter. below want :-

when list item clicked, model adapterview , pass jobsearchmodel. jobsearchmodel contains info want display on jobdescription fragement. don't know how add together fragement pop window.

searchresult.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> adapterview, view view, int i, long l) { jobsearchmodel jobs = (jobsearchmodel) adapterview.getitematposition(i); jobdescription jobdescription = new jobdescription(); bundle args = new bundle(); args.putserializable("jobs", jobs); jobdescription.setarguments(args); popupwindow.showatlocation(jobdescription, gravity.center, 0, 0); } });

copied here

the next should work perfect in accordance specification. phone call method within onclick(view v) of onclicklistener assigned view:

public void showpopup(view anchorview) { view popupview = getlayoutinflater().inflate(r.layout.popup_layout, null); popupwindow popupwindow = new popupwindow(popupview, layoutparams.wrap_content, layoutparams.wrap_content); // example: if have textview within `popup_layout.xml` textview tv = (textview) popupview.findviewbyid(r.id.tv); tv.settext(....); // initialize more widgets `popup_layout.xml` .... .... // if popupwindow should focusable popupwindow.setfocusable(true); // if need popupwindow dismiss when when touched outside popupwindow.setbackgrounddrawable(new colordrawable()); int location[] = new int[2]; // view's(the 1 clicked in fragment) location anchorview.getlocationonscreen(location); // using location, popupwindow displayed right under anchorview popupwindow.showatlocation(anchorview, gravity.no_gravity, location[0], location[1] + anchorview.getheight()); }

the comments should explain enough. anchorview v onclick(view v).

android android-layout android-activity android-fragments

No comments:

Post a Comment