返回
顶部

修改密码

Android Studio: Simple webview setup

+1

-1

收藏

+1

-1

点赞0

评论0

I have followed the instructions and information found in this thread: Webview load html from assets directory Which lead me to generate the following code: The html file, patchnotes.html: Hi there This is a page a simple page The XML refe…

I have followed the instructions and information found in this thread:

Webview load html from assets directory

Which lead me to generate the following code:

The html file, patchnotes.html:

<!DOCTYPE html><html><head> <title>Hi there</title></head><body> This is a page a simple page</body></html>

The XML reference to the webveiw I am using:

<WebViewandroid:id="@+id/webview"android:visibility="gone"android:layout_marginLeft="30dp"android:layout_marginTop="220dp"android:layout_width="200dp"android:layout_height="300dp"></WebView>

The Java code relevant to displaying the webview:

private void changeLog() {final View newsPanel = (View) findViewById(R.id.newsPanel);final TextView titleChangeLog = (TextView) findViewById(R.id.titleChangeLog);final WebView webview = (WebView) findViewById(R.id.webview);newsPanel.setVisibility(View.VISIBLE);titleChangeLog.setVisibility(View.VISIBLE);webview.setVisibility(View.VISIBLE);toggleMenu(newsPanel);}public class ViewWeb extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);WebView wv;wv = (WebView) findViewById(R.id.webview);wv.loadUrl("file:///android_asset/patchnotes.html");}}

I suspect perhaps it is something to do with the class ViewWeb never being called, but there is nothing at all in the example I linked above to suggest that you need to.

What happens when I execute this code is that nothing is displayed. There is no error, it just doesn’t display any of the content of the html file.

Any help here would be greatly appreciated, I am sure it is something simple I am missing.

Thank you.

扫一扫在手机打开

评论
已有0条评论
0/150
提交
热门评论
相关推荐
Get your hands on Android Studio 1.3,handsandroid
  • AndroidStudio
  • 2022-05-20 18:29
  • 9 0 0
+1
How to Use OpenCV in Android Studio,opencvandroid
  • AndroidStudio
  • 2022-05-20 18:29
  • 11 0 0
+1
Useful Android Studio Shortcuts
  • AndroidStudio
  • 2022-05-20 18:29
  • 5 0 0
+1
Android Studio tutorial for beginners
  • AndroidStudio
  • 2022-05-20 18:29
  • 11 0 0
+1
Android Studio: Simple webview setup
  • AndroidStudio
  • 2022-05-20 18:29
  • 7 0 0
+1
今日要闻
换一批
热点排行