I am having a base adapter like below :
public class GridViewAdapter extends BaseAdapter {
Context cont;
........
@Override
public View getView(int arg0, View convertView, ViewGroup arg2) {
View v;
TextView tv;
GridItemObject itemObject = (Constants.gridItemsList.get(arg0));
if (convertView == null) // if it’s not recycled, initialize some attributes
{
LayoutInflater li = (LayoutInflater) cont
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.grid_item, null);
tv = (TextView) v.findViewById(R.id.grid_item_textView1);
if(itemObject.isvisited)
{
tv.setText(itemObject.letter);
}
}
}
else
{
v = (View) convertView;
}
return v;
}
Constants.gridItemsList is a static list of type List < GridItemObject > which has few items(text set from 1 to 10) initially set with isvisited property as false.
The GridItemObject is a class which has definition as below :
public class GridItemObject
{
public String letter;
public boolean isvisited;
}
I want this gridview to be refreshed from another gridview which is as follows :
public class CustomGridViewAdapter extends BaseAdapter {
Context cont;
GridViewAdapter adapter;
// setting the values in constructor....
@Override
public int getCount() {
return 10;
}
@Override
public View getView(int arg0, View convertView, ViewGroup arg2) {
View v;
TextView tv;
LayoutInflater li = (LayoutInflater) cont
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.numbers_grid_item, null);
tv = (TextView) v.findViewById(R.id.numbers_grid_item_textView1);
tv.setText(arg0+"");
tv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
GridItemObject itemObject = (Constants.gridItemsList.get(arg0));
itemObject.isvisited = true;
adapter.notifyDataSetChanged();
}
});
I am using this gridview in my activity.
The issue is, I am not able to refresh GridViewAdapter adapter from CustomGridViewAdapter. When i click an item in CustomGridViewAdapter's gridview and check what's happening all the numbers are jumbled. Could someone suggest me on how to refresh a gridview from another (while using custom adapters in seperate files)