How to apply marquee to the Button programmatically in Android? -
i'm trying add marquee alert button(negative button) text. code:
builder.setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { toast.maketext(getapplicationcontext(), "clicked yes", toast.length_long).show(); } }); builder.setnegativebutton("dont showdont showdont showdont showdont showdont showdont showdont show", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); builder.setneutralbutton("dont show", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { toast.maketext(getapplicationcontext(), "clicked neutral", toast.length_long).show(); } }); alertdialog alertbox = builder.create(); alertbox.show(); button button = alertbox.getbutton(alertdialog.button_negative); if(button==null){ toast.maketext(getapplicationcontext(), "button null",toast.length_long).show(); } else { toast.maketext(getapplicationcontext(), button.gettext(), toast.length_long).show(); button.setellipsize(truncateat.marquee); button.setmaxlines(1); button.setselected(true); button.setmarqueerepeatlimit(10); }
i tried add following lines:
button.sethorizontallyscrolling(true);
but didn't display text of button itself. please me.
try please..
builder.setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { toast.maketext(getapplicationcontext(), "clicked yes", toast.length_long).show(); } }); builder.setnegativebutton("dont showdont showdont showdont showdont showdont showdont showdont show", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); builder.setneutralbutton("dont show", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { toast.maketext(getapplicationcontext(), "clicked neutral", toast.length_long).show(); } }); final alertdialog alertbox = builder.create(); alertbox.setonshowlistener(new onshowlistener() { @override public void onshow(dialoginterface dialog) { button posbtn =alertbox.getbutton(dialoginterface.button_positive); button negbtn =alertbox.getbutton(dialoginterface.button_negative); button neubtn =alertbox.getbutton(dialoginterface.button_neutral); linearlayout.layoutparams posparams = (linearlayout.layoutparams) posbtn.getlayoutparams(); posparams.weight = 1; posparams.width = layoutparams.match_parent; linearlayout.layoutparams negparams = (linearlayout.layoutparams) negbtn.getlayoutparams(); negparams.weight = 1; negparams.width = layoutparams.match_parent; linearlayout.layoutparams neuparams = (linearlayout.layoutparams) neubtn.getlayoutparams(); neuparams.weight = 1; neuparams.width = layoutparams.match_parent; posbtn.setlayoutparams(posparams); negbtn.setlayoutparams(negparams); neubtn.setlayoutparams(neuparams); } }); alertbox.show();