Issue
I am creating the custom control in android. That custom control should have the Tab with Webview. If i have used this custom control from user side, then they can access the webview events. I have tried the following,
CustomTab.java
public class CustomTab extends Activity
{
TabHost tabHost;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View m_vForm;
m_vForm = _createTABForm();
addTab("Tab1","Tab1");
addTab("Tab2","Tab2");
addTab("Tab3","Tab3");
addTab("Tab4","Tab4");
setContentView(m_vForm);
}
/** Create the TAB interface */
private ViewGroup _createTABForm() {
// construct the TAB Host
tabHost = new TabHost(this);
tabHost.setLayoutParams(
new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
// the tabhost needs a tabwidget, that is a container for the visible tabs
TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);
tabHost.addView(tabWidget, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
// the tabhost needs a frame layout for the views associated with each visible tab
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);
frameLayout.setPadding(0, 65, 0, 0);
tabHost.addView(frameLayout, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tabHost.setup();
return tabHost;
}
public void addTab(String tagid, String title)
{
// create the tabs
TabSpec ts1 = tabHost.newTabSpec(tagid);
ts1.setIndicator(title);
ts1.setContent(new TabHost.TabContentFactory(){
public View createTabContent(String tag)
{
LinearLayout panel = new LinearLayout(CustomTab.this);
panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
panel.setOrientation(LinearLayout.VERTICAL);
WebView webview=new WebView(CustomTab.this);
webview.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
panel.addView(webview);
return panel;
}
});
tabHost.addTab(ts1);
}
}
If the user passing the url, then it should be loaded in the specific webview, how can i identify which tab is selected, and how to load the url in a corresponding webview
.
Solution
I have solved this issue :-)
1. I have created 4 instances of WebView from user side class
2. Passed this with url to create the tab in CustomTab control
3. Inside the CustomTab, need to set the Content of Tab as this webview instance
4. After creation of Tab inside the CustomTab, should load this passed Url.
This is working for me.
Answered By - Ponmalar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.