大家好我是Android的新手,所以我想要你的帮助。我有一个gridview,我想要这个,例如当我点击第五项时第二项和第五项将被按下我怎么能这样做是可能的?
更新
这里是代码:
public View getView(final int arg0, final View arg1, ViewGroup arg2) {
final HashMap<String,ViewFlipper> hashMap=new HashMap<String,ViewFlipper>();
LayoutInflater layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ViewHolder viewHolder=new ViewHolder();
if(arg1==null){
view=new View(context);
view=layoutInflater.inflate(R.layout.view_flipper, null);
viewHolder.text=(TextView)view.findViewById(R.id.name);
viewHolder.image=(ImageView)view.findViewById(R.id.picture);
viewHolder.image.setImageResource(icons[arg0]);
}else{
view=(View)arg1;
}
final ViewFlipper flipper = (ViewFlipper)view.findViewById(R.id.my_view_flipper);
flipper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
// TODO Auto-generated method stub
AnimationFactory.flipTransition(flipper, FlipDirection.LEFT_RIGHT);
Animation animation=flipper.getInAnimation();
animation.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
flipper.setEnabled(false);
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
counter++;
hashMap.put(""+counter, flipper);
flipper.setEnabled(true);
Log.i("counter", ""+counter);
if(counter%2==0){
hashMap.get(""+counter).performClick();
}
}
});
}
});
return view;
}