I want to create a screen with menu of essays, how do I "reuse" a layout to have several essays and less layout (xml) files.
I want to create a screen with menu of essays, how do I "reuse" a layout to have several essays and less layout (xml) files.
You can have a Fragment
or a Activity
with a layout
fixed, receiving different parameters so that you can inflate the fields the way you want depending on the parameters received. Doing this you can hide fields that you do not use in a X case but use in case Y, using the function .setVisibility
Ex:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_padrao);
Textview txtNotaUm = (TextView)findViewById(R.id.txtNotaUm);
Textview txtNotaDois = (TextView)findViewById(R.id.txtNotaDois);
Boolean tipoUm = getIntent().getExtras().getBoolean("tipoUm");
if(tipoUm){
txtNotaUm.setVisibility(View.VISIBLE);
txtNotaDois.setVisibility(View.GONE);
}
else{
txtNotaUm.setVisibility(View.GONE);
txtNotaDois.setVisibility(View.VISIBLE);
}
}