简体   繁体   English

Android:如何在intent.putExtra中传递Webview

[英]Android: how to pass webview in intent.putExtra

I'm new to Android and am trying to make a simple app. 我是Android的新手,正在尝试制作一个简单的应用程序。

I want to create an activity which displays a webview loaded with an html. 我想创建一个活动,以显示一个加载了html的webview。 For the user experience to be good, I want to preload the html into the webview and pass that to the activity that displays it. 为了使用户体验良好,我想将html预加载到webview中,并将其传递给显示它的活动。 I'm not able to find any examples online which show how to pass webviews into the putExtra method. 我在网上找不到任何示例,这些示例展示了如何将Web视图传递到putExtra方法中。 Any ideas? 有任何想法吗?

@CommonsWare is right; @CommonsWare是正确的; you'll want to manage a hidden WebView on your page, load it, and then show it when the user wants to see it. 您需要管理页面上的隐藏WebView,加载它,然后在用户希望看到它时显示它。 This thread has some code that seems pretty close to what you are looking for. 该线程的某些代码似乎与您要查找的代码非常接近。

I have 2 activites: the first one preloads a url into a webview; 我有2个活动:第一个活动将网址预加载到Web视图中; the second one adds the webview to a layout and sets the content view with the layout. 第二个将Web视图添加到布局中,并使用该布局设置内容视图。

That is not going to work. 那是行不通的。 Just have one activity. 只需进行一项活动即可。

I want to pass the empty webview through intent.putExtra into the first activity. 我想通过intent.putExtra将空的webview传递到第一个活动中。

That is not possible. 这是不可能的。 Just have one activity. 只需进行一项活动即可。

I want to pass it into the second activity for adding it to the layout and setting the content view 我想将其传递到第二个活动中,以将其添加到布局并设置内容视图

One activity cannot show another activity's views. 一个活动无法显示另一个活动的视图。 Just have one activity. 只需进行一项活动即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM