如何在android中设置WebView?在android中的WebView
3
A
回答
12
0
**main.xml (res/layout)**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/urlEdit"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:inputType="textWebEditText"
android:imeOptions="actionDone" />
<Button
android:id="@+id/goButton"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_toRightOf="@id/urlEdit"
android:background="@drawable/redbutton"
android:text="Go..."
android:textColor="#fcfcfc" />
</RelativeLayout>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
的WebView Activtiy
public class WebViewExampleActivity extends Activity {
public WebView webView;
public Button goButton;
public EditText urlEdit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView)findViewById(R.id.webView);
goButton = (Button)findViewById(R.id.goButton);
urlEdit = (EditText)findViewById(R.id.urlEdit);
webView.setWebViewClient(new DemoWebViewClient());
goButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openUrl();
}
});
}
public void openUrl() {
String url;
url = urlEdit.getText().toString();
webView.loadUrl(url);
}
public class DemoWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
0
在这里,他们是
XML
<WebView
android:id="@+id/web_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" />
类
WebView webview = (WebView) findViewById(R.id.web_view);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.loadUrl("file:///android_asset/yourHtmlFile.html");
相关问题
- 1. 在Android的WebView中
- 2. android中的webview
- 3. android在android中的webView通知android
- 4. 在android中的webview颜色
- 5. 在webview url中的Android ID
- 6. 在webview中的android网页
- 7. Android ViewPager + Webview,ClassCastException!在viewpager中需要webview
- 8. G +在Android的webview
- 9. Webview中的Cookie android
- 10. webview中的Android youtube
- 11. WebView中的Cookie Android
- 12. Android - Webview onPageFinished,在
- 13. Android - webview中断
- 14. Android:在WebView中缩放SVG
- 15. Android - 在webview中加载PDF
- 16. 在Android App中优化Webview
- 17. 在Android WebView中播放Flash?
- 18. 在Android中与WebView交互
- 19. 在Android中使用WebView
- 20. 在WebView中设置Cookie android
- 21. android在webview中解析URL
- 22. Android:在tabview中推送webview
- 23. android webview - 页脚在中间?
- 24. 在android webview中使用javascript
- 25. 在WebView中的Android中文结构
- 26. 将ImageView放在Android中的WebView中
- 27. 在Android中的Webview中添加Javascript
- 28. 在android中的webview中加载网页?
- 29. 的Android的JavaScript中的WebView
- 30. Android:如何在android webview中启用cookie。
看看我的教程。 http://www.taiic.com/2011/03/12/webview-template-for-android-sdk/我也提供它的来源。 – GeneK