0

LinearLayoutUI をブロックせずにビューを追加したい。

@Override
protected void onPostExecute(RequestMySellingList result)
{

   for (MySellingData data : result.data)
   {
         LinearLayout rowSelling = (LinearLayout) inflater.inflate(R.layout.row_selling_item, null);

         ImageView iv_sellingItemImage = (ImageView) rowSelling.findViewById(R.id.iv_sellingItemImage);

         iv_sellingItemImage.setImageBitmap(data.bitmap);

         // Add rowSelling to the main list holder
         ll_sellingList.addView(rowSelling);
  }
}

注: ll_sellingListLinearLayoutエントリを保持します

onProgressUpdate()long-long json 応答を取得しているため使用できませんonPostExecute()。完全な json 要求を取得するメソッドを使用する必要があります。

問題は、リクエストが非常に長い場合です - addView が UI をブロックします

4

2 に答える 2

0

inflater.inflate()操作が重いため、UI をブロックします。また、findViewById安価な操作でもありません。そして、それらを for ループで何度も呼び出します。したがって、このように for ループの外に移動することをお勧めします。UI をブロックせずに高速に動作するかどうか試してみてください。

@Override
protected void onPostExecute(RequestMySellingList result)
{

     LinearLayout rowSelling = (LinearLayout) inflater.inflate(R.layout.row_selling_item, null);

     ImageView iv_sellingItemImage = (ImageView) rowSelling.findViewById(R.id.iv_sellingItemImage);

     for (MySellingData data : result.data)
     {
          iv_sellingItemImage.setImageBitmap(data.bitmap);

          // Add rowSelling to the main list holder
          ll_sellingList.addView(rowSelling);
     }
}
于 2013-11-03T20:32:51.653 に答える