0
我有android和gridview和customadapter問題。 (物品細胞包含imageview,3個文字瀏覽和2個按鈕)Xamarin安卓Gridview與CustomAdapter ART問題
2物理設備(1與Android 4.3(達爾維克),1與Android 5.1.1(藝術))。
在dalvik設備上,gridview滾動非常平滑。 在ART設備上,gridview滾動速度非常慢。
圖像由getview中調用的asynctask加載。
有什麼建議嗎?
下面是我的GetView代碼片段:
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = _orderItemLoader.OrderItems[position];
View itemView = LayoutInflater.From(_context).Inflate(Resource.Layout.OrderItemCell, parent, false);
var tvDisplayName = itemView.FindViewById<TextView>(Resource.Id.tvDisplayName);
var tvDisplayAmount = itemView.FindViewById<TextView>(Resource.Id.tvDisplayAmount);
var tvDisplayCount = itemView.FindViewById<TextView>(Resource.Id.textViewQuantity);
foreach (var _item in _orderItemLoader.OrderItems)
{
if (GetItemId(position) == _item.ItemId)
{
tvDisplayCount.Text = _item.Count.ToString();
break;
}
}
var btnPlus = itemView.FindViewById<Button>(Resource.Id.buttonPlus);
btnPlus.Focusable = false;
btnPlus.FocusableInTouchMode = false;
btnPlus.Clickable = true;
btnPlus.Tag = position;
btnPlus.Click += (s, e) =>
{
int pos = (int)((Button)s).Tag;
foreach (var itm in _orderItemLoader.OrderItems)
{
if (item.ItemId == GetItemId(position))
{
item.Count += 1;
tvDisplayCount.Text = item.Count.ToString();
break;
}
}
};
var btnMinus = itemView.FindViewById<Button>(Resource.Id.buttonMinus);
btnMinus.Focusable = false;
btnMinus.FocusableInTouchMode = false;
btnMinus.Clickable = true;
btnMinus.Tag = position;
btnMinus.Click += (s, e) =>
{
int pos = (int)((Button)s).Tag;
var tmpItem = GetItem(pos);
if (tmpItem != null)
{
if (tmpItem.Count > 1)
tmpItem.Count -= 1;
else
tmpItem.Count = 0;
tvDisplayCount.Text = tmpItem.Count.ToString();
}
};
var imgThumbail = itemView.FindViewById<ImageView>(Resource.Id.imgThumbnail);
imgThumbail.SetScaleType(ImageView.ScaleType.CenterCrop);
imgThumbail.SetPadding(8, 8, 8, 8);
tvDisplayName.Text = item.ItemName;
tvDisplayName.SetTextColor(Android.Graphics.Color.Black);
tvDisplayAmount.Text = ServiceManager.GetCurrency(item.Amount);
tvDisplayAmount.SetTextColor(Android.Graphics.Color.Black);
tvDisplayCount.SetTextColor(Android.Graphics.Color.Black);
new SetImageBitmapTask(item, imgThumbail, _activity).Execute("");
return itemView;
}
你的asyn任務代碼在哪裏 –
看看picasso圖片加載七段 –