How to programmatically set style attribute in a view

前端 未结 11 2034
北恋
北恋 2020-11-22 06:38

I\'m getting a view from the XML with the code below:

Button view = (Button) LayoutInflater.from(this).inflate(R.layout.section_button, null);
11条回答
  •  失恋的感觉
    2020-11-22 06:44

    Yes, you can use for example in a button

    Button b = new Button(this);
    b.setBackgroundResource(R.drawable.selector_test);
    

提交回复
热议问题