我想要在listView中動畫的一部分項目。 動畫在代碼中描述。動畫列表中的部分項目
什麼是最好的方式來做到這一點,而不會重載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