我想模糊一个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()'方法 –
发布完整实现。 –