Apply button style dinamycally

I have a little trouble: I will create dynamically material buttons applying @style/Widget.AppCompat.Button.Borderless style. Obviously if I create buttons in xml file to static buttons it works fine, but in java code I don't know how do this. This is my code

  for (String nameCat : cat){         Button button = new Button(getActivity());         lP = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, dpToPx(60)); // dpToPx is convert method         button.setLayoutParams(lP);          // text button         button.setText(nameCat);         // add to linear layout         lL.addView(button);     } 


if yu have your style in XML

 ContextThemeWrapper newContext = new ContextThemeWrapper(baseContext,;
    button = new Button(newContext);

Category: android Time: 2016-07-31 Views: 4

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.228 (s). 13 q(s)