Click here to Skip to main content
15,896,408 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had an array list i am generating buttons inside the gridview ,The problem is when i starting to scroll up/down, all the previous button on the grid starting to show in different places. My guess I have a problem with the getView function inside my adapter. Please any help



public class CustomAdapter extends BaseAdapter {

private ArrayList mButtons = null;

public CustomAdapter(ArrayList b)
{
mButtons = b;
}

@Override
public int getCount()
{
return mButtons.size();
}

@Override
public Object getItem(int position)
{
return (Object) mButtons.get(position);

}

@Override
public long getItemId(int position)
{
//in our case position and id are synonymous
return position;

}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
CustomButton button;
if (convertView == null) {
button =(CustomButton) mButtons.get(position);
}
else
{
button = (CustomButton) convertView;
}
return button;

}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900