Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue Regarding GridView Android
    primarykey
    data
    text
    <p>I have created gridview with 20 items. I have used custom adapter to bind this gridview. When i scroll in gridview the index of the items have been change, or sometime some of the items have been invisible. N some times whole gridview has been invisible. Not know what's worng with it. </p> <pre><code> public class MyAdapter extends BaseAdapter { final int NumberOfItem = 90; private Bitmap[] bitmap = new Bitmap[NumberOfItem]; View grid; private Context context; private LayoutInflater layoutInflater; MyAdapter(Context c){ context = c; layoutInflater = LayoutInflater.from(context); //init dummy bitmap, //using R.drawable.icon for all items /* for(int i = 1; i &lt; NumberOfItem; i++){ bitmap[i] = BitmapFactory.decodeResource(context.getResources(), R.drawable.image1); }*/ } @Override public int getCount() { // TODO Auto-generated method stub return imageIDs.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if(convertView==null){ grid = new View(context); grid = layoutInflater.inflate(R.layout.main, null); ImageView imageView = (ImageView)grid.findViewById(R.id.image); imageView.setBackgroundResource(imageIDs[position]); TextView textView = (TextView)grid.findViewById(R.id.text); textView.setText(names[position]); }else{ grid = (View)convertView; } return grid; } Integer[] imageIDs = { R.drawable.attorneys_180, R.drawable.auto_repair_180, R.drawable.coffee_180, R.drawable.gas_stations_180, R.drawable.grocery_180, R.drawable.hotels_180, R.drawable.locksmith_180, R.drawable.nightclubs_180, R.drawable.plumbers_180 }; String[] names = {"Attorneys","Auto Repair","Coffee","Gas Stations","Grocery","Hotels","Locksmith","NightClubs","Plumbers"}; } </code></pre> <p>content of main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center"&gt; &lt;ImageView android:id="@+id/image" android:layout_width="67dp" android:layout_height="67dp" android:background="@drawable/ic_launcher"/&gt; &lt;TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignRight="@+id/image" android:layout_below="@+id/image" android:text="gsdfgsd" android:textColor="#000000" android:gravity="center"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Give me right solution for it.</p> <p>Thanks, Jay Patel </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.
    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