Tôi lập trình tạo LinearLayout cho AlertDialog bằng một số nút.Android - Làm thế nào để lập trình kiểu nút trong Linearlayout?
tôi MUỐN để làm điều này:
<LinearLayout android:id="@+id/footer" android:layout_width="fill_parent"
style="@android:style/ButtonBar">
Nhưng với mã như thế này:
LinearLayout buttons = new LinearLayout(parentContext);
buttons.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams buttonsParams =
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
topLayout.addView(buttons, buttonsParams);
buttons.setLayoutParams(buttonsParams);
Button btnAdd = new Button(context);
btnAdd.setText("Add");
Làm thế nào tôi có thể thiết lập các phong cách của các nút (sử dụng một thanh nút) programmitically?
Đáng tiếc là nó là không thể. Bạn chỉ có thể thêm kiểu theo chương trình vào khoảng văn bản. –
Có thể điều này có thể giúp: http://stackoverflow.com/questions/2016249/how-to-programmatically-setting-style-attribute-in-a-view – 0gravity
không hoạt động http://stackoverflow.com/ Câu hỏi/3142067/android-set-style-in-code – user1365315