В настоящее время я работаю с макетом с вкладками ... Но на вкладках я хотел бы иметь веб-просмотры ...
Проблема, которую я получаю, состоит в том, что по какой-то причине из-за вкладок не должно работатьOverrideUrlLoading ион все еще открывает браузер ...
Вот мой источник:
Моя основная активность:
package app.numbers4sports.com;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TabHost;
public class numbers4sports extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, CounterActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("counter").setIndicator("COUNTER",
res.getDrawable(R.drawable.ic_tab_counter))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, HelpActivity.class);
spec = tabHost.newTabSpec("help").setIndicator("HELP",
res.getDrawable(R.drawable.ic_tab_help))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, HomeActivity.class);
spec = tabHost.newTabSpec("home").setIndicator("ORDER",
res.getDrawable(R.drawable.ic_tab_home))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
Моя домашняя активность (первое веб-просмотрение):
package app.numbers4sports.com;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class HomeActivity extends Activity {
WebView mWebView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.numbers4sports.com");
}
private class abcd extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}