我有一個編輯文本,我需要勾TextChanged事件,以做task.I已定義的overrdiimg的EditText上第一,但在文本chnaged事件添加文本提取代碼後,後所述IDE標誌的錯誤和經銷商通過在線 添加final
改性劑像這樣應用程序崩潰添加final修飾符來編輯文本
final EditText et1=(EditText)findViewById(R.id.editText1);
chnaging該應用crahses文本後校正它,所以我試圖以檢索所述的EditText第一2次用於鉤住到事件然後爲獲取文本,然後該應用程序崩潰。 IDE將促使我前添加在類似案件中final修飾符,但它已墜毀的應用程序,所以我不得不添加fetchbyID在這裏需要的對象點
EditText et1=(EditText)findViewById(R.id.editText1);
et1.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
new Thread(new Runnable() {
public void run() {
ImageView img=(ImageView)findViewById(R.id.imageView1);
EditText et=(EditText)findViewById(R.id.editText1);
img.setImageBitmap(thumbnail);
Bitmap b = workwithtext(thumbnail,et.getText().toString(),10);
img.setImageBitmap(b);
}
}).start();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
請幫我解決這個問題
好吧,我怎麼可以設置ImageView的,因爲過程可能會凍結用戶界面? – techno
你可以使用一個'AsyncTask',但我不明白爲什麼這應該在'onTextChanged進行()'。這意味着每次輸入一個字符時,都會設置圖像。這真的是你想要的嗎? –
怎麼樣?你可以給一個exmaple – techno