I have a relative layout and 'n' number of textviews and edittext . I want the alignment as
TextView EditText
Button
TextView EditText
Button
TextView EditText
Button
TextView EditText
Button
..........
I have tried using layout params but I am getting weird results. Here is my code,
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.linearlayoutid);
final TextView[] myTextViews = new TextView[41];
for (int i = 0; i < 41; i++) {
// create a new textview
rowTextView = new TextView(this);
RelativeLayout.LayoutParams paramsA = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
paramsA.addRule(RelativeLayout.RIGHT_OF, rowTextView.getId());
rowTextView.setId(i);
// add the textview to the layout
relativeLayout.addView(rowTextView, paramsA);
myTextViews[i] = rowTextView;
}
For Edit Text..
final EditText[] editTextarray = new EditText[41];
for (int i = 0; i < 41; i++) {
// create a new textview
final EditText editText = new EditText(this);
RelativeLayout.LayoutParams paramsB = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
editText.setText("edit");
editText.setCursorVisible(true);
relativeLayout.addView(editText, paramsB);
editTextarray[i] = editText;
}
I have applied layout_params like this but it didn't help. Any help would be great!! Thanks