0
有沒有辦法處理警報對話框中長時間的用戶輸入?我有一個小小的提醒對話框,需要幾個輸入,並且每當字符串輸入太長時,其他輸入和文本瀏覽都會被擠掉。有沒有辦法將字符串輸入放在不同的行上或包裝其他文本框的方式?我直接從代碼而不是XML創建alertdialog。用戶輸入太長,無法處理alertdialog
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);
是的,我在想,但問題是,即使是小到8個字符的字符串使其溢出 – user3155915
您可以嘗試在每個a,e,i,o,u,y或double之後加上( - )短劃線如果單詞不合適,則會顯示'll'和'rr'等字母。除非字符串在特定行中沒有元音,y,'rr'或'll',否則我們會遇到問題。它可能看起來像邏輯,邏輯,邏輯,\ nly等等(其中\ n表示行結束)。 –