2011-12-22 43 views
5

我有擴展webview的類(MyCustomWebView)我可以做這樣的事情嗎?如何在Android中創建自定義webview?

<MyCustomWebView 
    android:id="@+id/myCustomWebView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
/> 

如果沒有,我可以做這樣的事情。

WebView webView = (WebView) findViewById(R.id.webview); 
webView = new MyCustomWebView(this); 

回答

15

是的,你可以這樣做:

<your.package.MyCustomWebView android:id="@+id/myCustomWebView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    /> 

然後在代碼中,你可以這樣做:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView); 
相關問題