Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to flip all items in a gridview at a specific number of itemclicks
    primarykey
    data
    text
    <p>i am trying to do a kind of flipcard app in which there is gridview of images showing a same image ,say a card_back .</p> <p>On clicking each image,it flips showing another image which is different for every item of gridview,say a card_front.</p> <p>what i am trying to do is that ,if two card_front are shown,on clicking the next item,the first two cards should be flipped to show their card_back image.ie,at a time a maximum of only two cards can show their card_front image.But i dont know how to do that.</p> <p>Can anyone please help me out.Thanks in advance.</p> <p>This is the code for flipping images in gridview. </p> <pre><code> public class FullscreenActivity extends Activity implements OnItemClickListener, AnimationListener { ImageView imageView ; int pos; Animation animation1; Animation animation2; int[] clicked = {0,0,0,0,0,0,0,0,0,0,0,0}; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fullscreen); animation1 = AnimationUtils.loadAnimation(this, R.anim.to_middle); animation1.setAnimationListener(this); animation2 = AnimationUtils.loadAnimation(this, R.anim.from_middle); animation2.setAnimationListener(this); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { pos=position; imageView = ((ViewHolder) v.getTag()).img; (imageView).clearAnimation(); (imageView).setAnimation(animation1); (imageView).startAnimation(animation1); } }); } @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation arg0) { if (arg0==animation1) { if(clicked[pos]==0) { imageView.setImageResource(ImageAdapter.mThumbSelected[pos]); clicked[pos]=1; } else if(clicked[pos]==1) { clicked[pos]=0; imageView.setImageResource(R.drawable.card_back); } imageView.clearAnimation(); imageView.setAnimation(animation2); imageView.startAnimation(animation2); } } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload