У меня динамически создаются вкладки, в которых я затем программно добавляю GridView с помощью перетаскивателя n
. Все работает, если есть только одна вкладка, но если вы перейдете ко второму, переместите элементы, а затем обратно, он сработает. Я верю, потому что обе вкладки используют один и тот же mDragController. Должно быть довольно легко исправить любые идеи, как заставить их использовать отдельные контроллеры?Перетаскивание динамически созданных GridViews
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;
}
}
сэр Пожалуйста, ответьте на этот вопрос [ссылка] (http://stackoverflow.com/questions/20988505/open-child-activity-in-tab-host-android) –