Okay, so that's the problem: When I try to create dynamically some checkboxes, they don't get the material theme even if I'm inflating them from an xml file.
EDIT:
java:
setContentView(R.layout.activity_volumi);
FloatingActionButton add = (FloatingActionButton) findViewById(R.id.add);
final LinearLayout ll = (LinearLayout) findViewById(R.id.home);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Aggiunta", Toast.LENGTH_SHORT).show();
LinearLayout ll4;;// = new LinearLayout(getApplicationContext());
ll4 = (LinearLayout) View.inflate(getApplicationContext(), R.layout.volume, null);
ll.addView(ll4);
//CheckBox cb;// = new CheckBox(getApplicationContext());
//cb = (CheckBox) View.inflate(getApplicationContext(), R.layout.dynamic_check, null);
//cb.setText("I'm dynamic!");
//cb.setBackgroundColor(getResources().getColor(R.color.myPrimaryColor));
//cb.setId();
Toast.makeText(getApplicationContext(), "Aggiunto", Toast.LENGTH_SHORT).show();
}
});
EDIT:
Thanks to Riccardo Ciovati now it works :D
If it's only about checkboxes, you can instantiate a tint-aware CheckBox
with the AppCompatCheckBox class.
There are other similar classes, like
You can inflate them directly with a specific theme. Look in the docs there are several inflate methods
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.