Saturday, 15 June 2013

android - add an existing button to the action bar(show popup button) -



android - add an existing button to the action bar(show popup button) -

i made pause button opens popup 3 buttons, resume,music on/off,reset.

my problem button on screen , takes place , it's ugly.. want set button on action bar.. how can it?

here button:

<button android:id="@+id/show_popup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/button1" android:layout_alignleft="@+id/youlost" android:layout_alignparentright="true" android:background="@drawable/pausesign" />

here popup dialog code:

@override public void onwindowfocuschanged(boolean hasfocus) { int[] location = new int[2]; button button = (button) findviewbyid(r.id.show_popup); button.getlocationonscreen(location); p = new point(); p.x = location[0]; p.y = location[1]; } private void showpopup(final activity context, point p) { int popupwidth = 2000; int popupheight = 1200; linearlayout viewgroup = (linearlayout) context.findviewbyid(r.id.popup); layoutinflater layoutinflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); view layout = layoutinflater.inflate(r.layout.popup_layout, viewgroup); final popupwindow popup = new popupwindow(context); popup.setcontentview(layout); popup.setwidth(popupwidth); popup.setheight(popupheight); popup.setfocusable(true); int offset_x = 60; int offset_y = 60; popup.showatlocation(layout, gravity.no_gravity, p.x + offset_x, p.y + offset_y); button close = (button) layout.findviewbyid(r.id.close); button restart = (button) layout.findviewbyid(r.id.restart); final button music = (button) layout.findviewbyid(r.id.music); musicstop = (button) layout.findviewbyid(r.id.musicstop); musicstop.setvisibility(view.gone); music.setonclicklistener(new onclicklistener() { public void onclick(view v) { mplayer.pause(); musicstop.setvisibility(view.visible); music.setvisibility(view.gone);} }); musicstop.setonclicklistener(new onclicklistener() { public void onclick(view v) { musicstop.setvisibility(view.gone); music.setvisibility(view.visible); mplayer.start(); } }); close.setonclicklistener(new onclicklistener() { public void onclick(view v) { popup.dismiss(); } }); restart.setonclicklistener(new onclicklistener() { public void onclick(view v) { popup.dismiss(); highscore_int.settext(""); youlost.settext("game restarted"); counter=0; timecounter=0; timecounter1=0; timecounter2=0; timecounter3=0; timecounter4=0; changingtextview.settext(""+counter); button6.setbackgroundcolor(color.rgb(timecounter, timecounter, timecounter)); button5.setbackgroundcolor(color.rgb(timecounter1*2, timecounter1*2, timecounter1*2)); button4.setbackgroundcolor(color.rgb(timecounter2*3, timecounter2*3, timecounter2*3)); button3.setbackgroundcolor(color.rgb(timecounter3*4, timecounter3*4, timecounter3*4)); button1.setbackgroundcolor(color.rgb(timecounter4*5, timecounter4*5, timecounter4*5)); mplayer.start(); } }); }

how can add together button action bar?

android

No comments:

Post a Comment