我想模糊一個ListView項目。我模糊的CustomListViewAdapter的getView()(使用模糊庫):如何模糊ListView項目與模糊?
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
final AirdropResult airdrop = getItem(position);
boolean bWasNull = false;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.result_item, parent, false);
bWasNull = true;
}
final RelativeLayout airdropListRowInside = (RelativeLayout) convertView.findViewById(R.id.airdropListRowInside);
final TextView tvName = (TextView) airdropListRowInside.findViewById(R.id.tvCoinName);
final TextView tvDesc = (TextView) airdropListRowInside.findViewById(R.id.tvDesc);
final TextView tvStartdate = (TextView) airdropListRowInside.findViewById(R.id.tvStartdate);
tvName.setText(airdrop._name);
tvDesc.setText(airdrop._shortdesc);
if(bWasNull) {
convertView.post(new Runnable() {
@Override
public void run() {
Blurry.with(getContext())
.radius(5)
.sampling(2)
.async()
.animate(100)
.onto(airdropListRowInside);
}
});
}
return convertView;
}
好像佈局變得模糊,但隨後呈現在上面不模糊的佈局(只有一個佈局)。我使用Runnable because it is apparently needed。
我假設這是因爲ListView如何重用項目,但沒有足夠的理解來解決它。有人可以幫忙嗎?
Post Full'getView()'方法 –
發佈完整實現。 –