Reputation: 1592
Text within my textview within my fragment has a few links. I need to display them in a webview. The links point to a few webpages in my assets folder. How do go about it?
Upvotes: 0
Views: 88
Reputation: 1634
Just load your web asset from your code.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//....
Webview wv = (WebView) layout. findViewById(R.id.webview);
wv.loadUrl("file:///android_asset/web.html");
return layout;
}
Upvotes: 1
Reputation: 5451
Have a new Activity named as WebviewActivity and put below code in it's java file:
public class WebviewActivity extends Activity {
WebView webview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webview= (WebView) findViewById(R.id.webView1);
webview.loadUrl("file:///android_asset/your file_name.html");
}
}
Hope it will help you.
Upvotes: 1