I have created the action bar and tabs dynamically like the below code.
For creating the action bar:
public void addTabBar(Context context)
{
sActiveContext=context;
sActionBar = getActionBar();
sActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}
For dynamically creating the tab bars in the action bar:
public void addTabItem(final String url, String tabTitle)
{
arrayList.add(url);
Tab tab = sActionBar.newTab();
if(tabTitle.equals(""))
{
int childcount=sActionBar.getTabCount();
tabTitle="Tab" + String.valueOf(childcount+1);
}
tab.setText(tabTitle);
tab.setTabListener(this);
sActionBar.addTab(tab);
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
linearLayout=new LinearLayout(sActiveContext);
linearLayout.setLayoutParams(new
LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
setContentView(linearLayout);
CustomWebView webview=new CustomWebView(sActiveContext);
FrameLayout layout=webview.createwebview();
for (int i = 0; i < arrayList.size(); i++) {
if(tab.getPosition()==i)
{
webview.initwebview(arrayList.get(i));
break;
}
}
linearLayout.addView(layout);
}
I am having the customized webview inside the framelayout. So, I directly
call the method and get the webview in framelayout and add this into the
linearlayout and added the linearlayout as the content of the created tab
item. I am nothing doing in the onTabUnselected() method. Now, my question
is, If I am switching between the tabs, the content of the tab is newly
created. If I am switch this concept to fragments means, I have to create
the Fragment class dynamically not the fragment. Now, how can I control the
tab content re-creating issue.
Regards
Karthick Raja
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.