【发布时间】:2014-07-07 01:08:07
【问题描述】:
有没有办法处理警报对话框中的长用户输入?我有一个小的警报对话框,需要一些输入,每当字符串输入太长时,其他输入和文本视图都会被压扁。有没有办法将字符串输入放在不同的行或包装其他文本字段的方法?我直接从代码而不是 XML 创建警报对话框。
LinearLayout layout = new LinearLayout(this);
EditText weight = new EditText(this);
EditText mark = new EditText(this);
TextView marktext = new TextView(this);
marktext.setText("Mark");
TextView weighttext = new TextView(this);
weighttext.setText("Weight");
mark.setInputType(InputType.TYPE_CLASS_NUMBER);
weight.setInputType(InputType.TYPE_CLASS_NUMBER);
//Assignment name input
EditText workType = new EditText(this);
workType.setInputType(InputType.TYPE_CLASS_TEXT);
TextView workTypeText = new TextView(this);
workTypeText.setText("Name of the work: ");
weight.setId(99);
mark.setId(100);
workType.setId(9999);
/*Spinner addworkspinner = new Spinner(this);
ArrayAdapter<String> addworkadapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, ClassManager.possiblework);
addworkspinner.setAdapter(addworkadapter); */
layout.addView(workTypeText);
layout.addView(workType);
layout.addView(marktext);
layout.addView(mark);
layout.addView(weighttext);
layout.addView(weight);
AlertDialog.Builder addwork = new AlertDialog.Builder(this);
addwork.setTitle("Add a piece of work");
addwork.setView(layout);
【问题讨论】:
标签: java android android-alertdialog