Reputation: 41
When the second tab is clicked the contents are shown over the content of the first tab. The first tab contents are still visible underneath. Here's some sample code:
MainActivity.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Home tab
Intent intentHome = new Intent().setClass(this, home.class);
TabSpec tabSpecHome = tabHost
.newTabSpec("Home")
.setIndicator("Home", ressources.getDrawable(R.layout.icon_home))
.setContent(intentHome);
// Tools tab
Intent intentTools = new Intent().setClass(this, tools.class);
TabSpec tabSpecTools = tabHost
.newTabSpec("Tools")
.setIndicator("Tools", ressources.getDrawable(R.layout.icon_tools))
.setContent(intentTools);
ToolsActivity.java
public class tools extends Activity {
public static tools self;
private ImageButton imageButton1;
private WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tools);
addListenerOnButton1();
public void addListenerOnButton1() {
imageButton1=(ImageButton)findViewById(R.id.imageButton1);
imageButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
setContentView(R.layout.activity_web);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("file:///android_asset/www/tools/calculators.html");
webView.setBackgroundColor(Color.parseColor("#111111"));
}
});
}
MainActivity.java uses activity_main.xml and Tools.java uses activity_tools.xml both of which are the same in layout but differ slightly in content.
I tried putting Finish(); at the end of each TabSpec in MainActivity.java but that simply closed the app in the emulator as I suspected it would.
Does anyone have any guidance they could give me?
Thanks in advance.
Upvotes: 0
Views: 99
Reputation: 2885
just remove this line :
webView.setBackgroundColor(Color.parseColor("#111111"));
Upvotes: 1
Reputation: 6899
Try this,
In Manifest.xml, for activity, use this,
android:noHistory="true"
Upvotes: 0