I want to add aEditText
below aNumberPicker
in the below code, currently aEditText
is appearing in the top left corner of the alert, how would you manage to get it below aNumberPicker
public void onClickNotes(View view)
{
Context mContext = this;
RelativeLayout linearLayout = new RelativeLayout(mContext);
final NumberPicker aNumberPicker = new NumberPicker(mContext);
final EditText aEditText = new EditText(mContext);
aNumberPicker.setMaxValue(50);
aNumberPicker.setMinValue(1);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50);
RelativeLayout.LayoutParams numPickerParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams EditParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
numPickerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
linearLayout.setLayoutParams(params);
linearLayout.addView(aNumberPicker,numPickerParams);
EditParams.addRule(RelativeLayout.ABOVE, 0);
linearLayout.addView(aEditText,EditParams);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
alertDialogBuilder.setTitle("Entry Index");
alertDialogBuilder.setView(linearLayout);
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("Select",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
//aNumberPicker.getValue();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}