I have dynamically created tabs, in which I then programatically add a GridView with dragn
drop controller. It all works if its only one tab, but if you scroll to the second one, rearrange items and then back, it crashes. I believe its because both tabs are using the same mDragController. It should be fairly easy to fix, any Ideas how to make them use separate controllers?
private DragController mDragController;
private boolean mLongClickStartsDrag = true; // If true, it takes a long click
protected void onCreate(Bundle savedInstanceState) {
...
final TabHost Tabs = (TabHost) findViewById(android.R.id.tabhost);
Tabs.setup();
int count;
for (count =0;count < 2;count++){
...
final int passedTabId = count;
NewTab.setContent(new TabHost.TabContentFactory()
{
public View createTabContent(String tag)
{
...
GridView dynGrid = new GridView(ManageRooms.this);
...
mDragController = new DragController (ManageRooms.this);
dynGrid.setAdapter (new ImageCellAdapter (ManageRooms.this, mDragController));
layout.addView(dynGrid);
return layout;
}
});
Tabs.addTab(NewTab);
}
}
public boolean startDrag (View v) {
v.setOnDragListener (mDragController);
mDragController.startDrag (v);
return true;
}
}