i want to create Edittext and Textview dynamically such that textView appears in left and EditText appears in right .This all will be done in alert dialog box.but edit text are appearing multiple times
here is my code
AlertDialog.Builder builder1 = new AlertDialog.Builder(chooses.this);
builder1.setMessage("Please enter Your Budget");
int prevTextViewId = 0;
RelativeLayout relativeLayout = new RelativeLayout(chooses.this);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
relativeLayout.setLayoutParams(rlp);
TextView textView[]=new TextView[ checked.length];
EditText input[]=new EditText[ checked.length];
for(int j = 0; j < checked.length; j++)
{
textView[j]= new TextView(chooses.this);
textView[j].setText(checked[j]);
int curTextViewId = prevTextViewId + 1;
textView[j].setId(curTextViewId);
final RelativeLayout.LayoutParams paramss =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
paramss.addRule(RelativeLayout.BELOW, prevTextViewId);
textView[j].setLayoutParams(paramss);
input[j] = new EditText(chooses.this);
input[j].setId(curTextViewId+20);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF,textView[j].getId());
lp.addRule(RelativeLayout.ALIGN_BASELINE,textView[j].getId());
lp.addRule(RelativeLayout.ALIGN_BOTTOM,textView[j].getId());
input[j].setLayoutParams(lp);
prevTextViewId = curTextViewId;
relativeLayout.addView(textView[j]);
relativeLayout.addView(input[j]);
}
builder1.setView(relativeLayout);
builder1.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
my output looks like this
textViewelement edittextelement
edittextelement
edittextelement
edittextelement
please help i stuck in this problem for almost 8 hours thanks in anvance