2011-12-22 4 views
5

J'ai une classe (MyCustomWebView) qui étend Webview puis-je faire quelque chose comme ça?Comment créer un webview personnalisé sur Android?

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

sinon, pourrais-je faire quelque chose comme ceci.

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

Répondre

15

Oui, vous pouvez le faire:

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

Ensuite, dans le code que vous pouvez faire ceci:

MyCustomWebView myWebView = (MyCustomWebView) findViewById(R.id.myCustomWebView); 
Questions connexes