Task:
Under an Android app, an outsourced style is to be transferred to newly created presentation elements at runtime.
The style is stored in a file under res / drawable / xml.
Solution:
You can with getDrawable (..) determine and adopt the style of presentation
In Android Java at runtime:
Drawable
background_XML= getDrawable(R.drawable.table_layout); |
This will determine the style stored in an xml file and apply it to a display element such as a table, TableRow, or cell TextView
Here is the display style stored in the file table_layout.xml under
/res/drawable/table_layout.xml.
The display style is found using getDrawable
Drawable background_XML= getDrawable(R.drawable.table_layout); |
Xml code of the table_layout file
Table_layout.xml
<?xml version="1.0" encoding="utf-8"?> |
Example how the TAbelle is dynamically filled at runtime with further rows of tables and cells and in which the display is taken over.
public void create_Table(){
|
After the start, the two lower cells are inserted and the display is taken over
Subject:
Android Drawable Style
Android Studio, Android Java at runtime