ListView
収集に時間がかかるテキスト情報を入力する必要があります。getView()
私のアプローチは、AsyncTaskを使用してバックグラウンドジョブを実行することですが、結果が到着したときにテキストをTextViewに設定すると、リストの速度が低下します。リストは、呼び出されるたびに遅れます。
これは私のAsyncTask
クラスです
private class BreadcrumbTask extends AsyncTask<FFile, Void, String>{
private WeakReference<TextView> mTextView;
public BreadcrumbTask(TextView textView){
mTextView = new WeakReference<TextView>(textView);
}
@Override
protected String doInBackground(FFile... params) {
// text processing
}
@Override
protected void onPostExecute(String result) {
if (mTextView != null){
TextView tv = mTextView.get();
if (tv != null)
//this line blocks the UI. if I comment it the lag is gone
tv.setText(result);
}
// mTextView.setText(result); }
getView()で新しいタスクを作成し、それを実行します。問題は明らかにから来てtv.setText(result)
いonPostExecute()
ます。コメントすると、リストはうまく流れます。TextView
では、UIを遅くせずにを更新するにはどうすればよいですか?