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);     } 

Replay

if yu have your style in XML

 ContextThemeWrapper newContext = new ContextThemeWrapper(baseContext, R.style.MyStyle);
    button = new Button(newContext);

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

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.226 (s). 12 q(s)