我開發某種聊天應用程序,一切都很好,但我堅持一個問題。 EditText滯後,我的android鍵盤在第二次或者在我在edittext中鍵入一些字母時被凍結。我不知道要提供什麼代碼,因爲它只是一個簡單的EditText框。以下是我如何做到這一點:android EditText輸入文字滯後
linforbutton.add(new LinearLayout(this)); //linear layout on the bottom os creen for edittext and button
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
linforbutton.get(x).setLayoutParams(params);
linforbutton.get(x).setBackgroundColor(0xff426193);
linforbutton.get(x).setOrientation(LinearLayout.HORIZONTAL);
int padding_in_dp1 = 3;
final float scale1 = getResources().getDisplayMetrics().density;
int padding_in_px1 = (int) (padding_in_dp1 * scale1 + 0.5f);
linforbutton.get(x).setPadding(0, 0, 0, 0);
relmsg.get(x).addView(linforbutton.get(x));
msginput.add(new EditText(this));
msginput.get(x).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
msginput.get(x).setMaxLines(3);
msginput.get(x).setMinLines(1);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
msginput.get(x).setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
msginput.get(x).setImeOptions(EditorInfo.IME_ACTION_SEND);
msginput.get(x).setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
linforbutton.get(x).addView(msginput.get(x));
btninput.add(new Button(this));
btninput.get(x).setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btninput.get(x).setText("Отпр.");
int padding_in_dp2 = 20;
final float scale2 = getResources().getDisplayMetrics().density;
int padding_in_px2 = (int) (padding_in_dp2 * scale2 + 0.5f);
btninput.get(x).setPadding(padding_in_px2, 0, padding_in_px2, 0);
linforbutton.get(x).addView(btninput.get(x));
林進行一些意見,所以我有一個for循環,不看數組。我試圖刪除數組,並只有一個視圖一個edittext一個按鈕,並沒有奏效。
你有多個線程/或異步任務嗎? – 2011-05-30 07:54:08
我在我的應用程序中總共有6個線程 – artouiros 2011-05-30 07:55:35
那麼這可能是您的問題。看看你是否可以添加一些暫停到你的一些線程來提高性能。 – DKIT 2011-05-30 09:51:01