Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display the next images by clicking on the "next" button
    primarykey
    data
    text
    <p>I am trying to display the image by clicking on the "next" button but this code doesn't work.</p> <pre><code>import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.GridView; import android.widget.ImageView; import android.widget.Toast; public class MyGridView extends Activity { GridView mGridView; int counter,i; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.mygridacti); mGridView = (GridView)findViewById(R.id.grdvw); //mGridView.setAdapter(new MyImageAdapter(this)); ImageView imageview = (ImageView)findViewById(R.id.GalleryView); Button btnnext = (Button)findViewById(R.id.btn_nxt); Log.i("counter", ""+counter); btnnext.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //for(i=0;i&lt;=5;i++){ mGridView.setAdapter(new MyImageAdapter(getApplicationContext())); Log.i("counter", ""+counter); //} // TODO Auto-generated method stub //mGridView.setAdapter(new MyImageAdapter(getApplicationContext())); //Toast.makeText(MyGridView.this, "No Images", Toast.LENGTH_SHORT).show(); } } ); } } class MyImageAdapter extends BaseAdapter{ private Context mContext; ImageView imageview; int counter; public MyImageAdapter(Context c){ mContext = c; } public MyImageAdapter(OnClickListener onClickListener) { // TODO Auto-generated constructor stub } @Override public int getCount() { // TODO Auto-for(i = 6;i&lt;=counter;i++) {generated method stub //counter = mThumbsIds.length; //System.out.println("Counter = "+counter); return 5; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if(convertView == null){ imageview = new ImageView(mContext); imageview.setLayoutParams(new GridView.LayoutParams(85,85)); imageview.setScaleType(ImageView.ScaleType.CENTER_CROP); imageview.setPadding(8, 8, 8, 8); } else{ imageview = (ImageView) convertView; } //int[] mThumbIds = null; imageview.setImageResource(mThumbsIds[position]); return imageview; //return null; } private Integer[] mThumbsIds = { R.drawable.image1,R.drawable.image2, R.drawable.image3,R.drawable.image4, R.drawable.image5,R.drawable.icon, R.drawable.icon,R.drawable.icon, R.drawable.icon}; } </code></pre> <p>Please help me out to correct this.</p>
    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.
 

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