@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // add this code
LinearLayout milay = (LinearLayout) this.findViewById(R.id.milay);
final int N = 3; // total number of textviews to add
final TextView[] myTextViews = new TextView[N]; // create an empty array;
for (int i = 0; i < N; i++) {
// create a new textview
Toast.makeText(getApplicationContext(), "This is row #" + i, Toast.LENGTH_SHORT).show();
final TextView rowTextView = new TextView(this);
// set some properties of rowTextView or something
rowTextView.setText("This is row #" + i);
// add the textview to the linearlayout
milay.addView(rowTextView);
// save a reference to the textview for later
myTextViews[i] = rowTextView;
}
setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
}
Se que hace el proceso bien, pero a la hora de mostrarlo no sale nada en el LinearLayout .
Que estoy haciendo mal o que me falta... ? =?