Generate a XML layout file dinamically



In my current spring project, one of my activities should be a form where the user can insert a new entity. the code for the activity is like this:



public class FormNewItemActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.form_new_item_view);

Intent intent = getIntent();
Dao<?> dao = intent.getStringExtra(HelloActivity.EXTRA_MESSAGE);
}
}


the layout file should have a list of EditText fields and a unique Button in the end for trigger the saving of the data in a SQLite database.


I wonder if it's possible, giving a list of string with the name of the fields of the entity class, generate a xml layout file dinamically with one EditText for each field.


Anyone knows if this is really possible and how can be done?


No comments:

Post a Comment