listView内の項目の一部をアニメーションしたいと思います。 アニメーションはコードで記述されています。List内の項目の一部にアニメーションを適用する
mainThreadをオーバーロードせずにこれを行うにはどうすればよいですか?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
StockExchangeModel stockExchangeModel = mStockExchangeModels.get(position);
ViewHolder holder;
if (convertView == null){
convertView = ((LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.item_stock_exchange, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (stockExchangeModel.isNeedAnim()){
// blink color RED
// wait 0.2s
// return to start color
// wait 0.2s
// blink color RED
// wait 0.2s
// return to start color
}
holder.value.setText(String.format("%.2f",stockExchangeModel.getValue()));
holder.change.setText(stockExchangeModel.getChange());
holder.name.setText(stockExchangeModel.getName());
return convertView;
}
単にasynctaskを使用してください。 –
これを行うにはこれが最善の方法だとは思わない – Esperanz0
@MarcoBarbosaこれはアプリケーションをクラッシュさせる原因になります。別のスレッドでビューを更新することはできません。 – Linxy