I write a method to generate gallery at run time.
private Gallery createGallery(ImageAdapter imageAdapter) {
Gallery sampleGallery = new Gallery(getApplicationContext());
sampleGallery.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
sampleGallery.setGravity(Gravity.FILL_VERTICAL);
sampleGallery.setSpacing(5);
sampleGallery.setAdapter(imageAdapter);
sampleGallery.setSelection(1);
return sampleGallery;
}
Then I create a galley and try to set it to a Tab Layout.
final TabHost mTabHost = (TabHost) findViewById(R.id.tabHost);
mTabHost.setup();
Gallery tabGallery = createGallery(brkingNewAdapter); // my image adapter
tabGallery.setId(R.id.gallery_1);
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1")
.setContent(R.id.gallery_1));
R.id.gallery_1 is defined as mentions in here.
I get a exception as follows.
Could not create tab content because could not find view with id 2130968576
Any help on this?
Thank you in advance.