无法通过 onItemClickListener ListView 的方法为 ImageView 设置动画。ListView 位于片段内。有人可以建议我该怎么做吗?
public class MainFragment extends Fragment {
View view;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sis){
View view = inflater.inflate(R.layout.fragment_layout, container, false);
ListView lv = (ListView)view.findViewById(R.id.listf);
this.view= view;
lv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
ImageView i = (ImageView)view.findViewById(R.id.imgv);
AnimationSet as = new AnimationSet(true);
Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.anim1);
Animation animation2 = AnimationUtils.loadAnimation(this, R.anim.anim2);
as.addAnimation(animation1);
as.addAnimation(animation2);
i.setImageResource(R.drawable.logocpic1);
i.startAnimation(as);
}
}