{"id":23781,"date":"2023-12-13T11:59:56","date_gmt":"2023-12-13T03:59:56","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=23781"},"modified":"2023-12-13T11:59:56","modified_gmt":"2023-12-13T03:59:56","slug":"%e7%bd%91%e9%a1%b5%e5%b0%81%e8%a3%85%e5%ae%89%e5%8d%93%e6%9c%89%e5%93%aa%e4%ba%9b%e6%96%b9%e6%b3%95%e5%91%a2","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/23781.html","title":{"rendered":"\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u6709\u54ea\u4e9b\u65b9\u6cd5\u5462?"},"content":{"rendered":"<p>\u7f51\u9875\u5c01\u88c5\u5b89\u5353\uff0c\u4e5f\u79f0\u4e3aWebview\uff0c\u662f\u4e00\u79cd\u5728\u5b89\u5353\u5e94\u7528\u4e2d\u5d4c\u5165\u7f51\u9875\u7684\u6280\u672f\u3002\u901a\u8fc7\u4f7f\u7528Webview\u6280\u672f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5c06\u7f51\u9875\u5d4c\u5165\u5230\u5b89\u5353\u5e94\u7528\u4e2d\uff0c\u5b9e\u73b0\u539f\u751f\u5e94\u7528\u4e0e\u7f51\u9875\u7684\u65e0\u7f1d\u8854\u63a5\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u539f\u7406\u4ee5\u53ca\u5b9e\u73b0\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e00\u3001\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u539f\u7406<\/p>\n<p>\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u539f\u7406\u975e\u5e38\u7b80\u5355\uff0c\u5c31\u662f\u901a\u8fc7WebView\u63a7\u4ef6\u5c06\u7f51\u9875\u5d4c\u5165\u5230\u5b89\u5353\u5e94\u7528\u4e2d\u3002WebView\u662f\u5b89\u5353\u7cfb\u7edf\u63d0\u4f9b\u7684\u4e00\u4e2a\u63a7\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7d\u7f51\u9875\uff0c\u5e76\u5c06\u5176\u663e\u793a\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u4e2d\u3002WebView\u662f\u4e00\u4e2a\u652f\u6301HTML\u3001CSS\u3001JavaScript\u7b49\u7f51\u9875\u6280\u672f\u7684\u63a7\u4ef6\uff0c\u5b83\u53ef\u4ee5\u52a0\u8f7d\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u5c06\u5176\u663e\u793a\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u4e2d\u3002<\/p>\n<p>\u5728\u4f7f\u7528WebView\u63a7\u4ef6\u65f6\uff0c\u9700\u8981\u901a\u8fc7Java\u4ee3\u7801\u6765\u5b9e\u73b0\u7f51\u9875\u7684\u52a0\u8f7d\u548c\u663e\u793a\u3002\u9996\u5148\uff0c\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\u3002\u7136\u540e\uff0c\u901a\u8fc7Java\u4ee3\u7801\u83b7\u53d6\u8be5\u63a7\u4ef6\u7684\u5f15\u7528\uff0c\u5e76\u8bbe\u7f6e\u5b83\u7684\u5c5e\u6027\uff0c\u5982\u52a0\u8f7d\u7684\u7f51\u9875\u5730\u5740\u3001\u663e\u793a\u6a21\u5f0f\u7b49\u3002\u6700\u540e\uff0c\u5c06WebView\u63a7\u4ef6\u6dfb\u52a0\u5230\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u4e2d\uff0c\u5b8c\u6210\u7f51\u9875\u7684\u663e\u793a\u3002<\/p>\n<p>\u4e8c\u3001\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u5b9e\u73b0\u8fc7\u7a0b<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u5177\u4f53\u4ecb\u7ecd\u4e00\u4e0b\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002<\/p>\n<p>1. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b89\u5353\u9879\u76ee<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b89\u5353\u9879\u76ee\u3002\u5728\u521b\u5efa\u9879\u76ee\u65f6\uff0c\u9700\u8981\u9009\u62e9\u201cEmpty Activity\u201d\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u6a21\u677f\uff0c\u8fd9\u6837\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u7a7a\u767d\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>2. \u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0WebView\u63a7\u4ef6<\/p>\n<p>\u5728\u521b\u5efa\u597d\u9879\u76ee\u4e4b\u540e\uff0c\u9700\u8981\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\u3002\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`xml<\/p>\n<\/p>\n<p>    android:id=&#8221;@+id\/webview&#8221;<\/p>\n<p>    android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>    android:layout_height=&#8221;match_parent&#8221;\/&gt;<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5b9a\u4e49\u4e86\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u5e76\u8bbe\u7f6e\u5176\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u4e3a\u201cmatch_parent\u201d\uff0c\u5373\u4e0e\u7236\u5bb9\u5668\u76f8\u540c\u3002\u8fd9\u6837\u53ef\u4ee5\u4f7fWebView\u63a7\u4ef6\u5145\u6ee1\u6574\u4e2a\u5c4f\u5e55\u3002<\/p>\n<p>3. \u5728Java\u4ee3\u7801\u4e2d\u52a0\u8f7d\u7f51\u9875<\/p>\n<p>\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e86WebView\u63a7\u4ef6\u4e4b\u540e\uff0c\u9700\u8981\u5728Java\u4ee3\u7801\u4e2d\u52a0\u8f7d\u7f51\u9875\u3002\u5728MainActivity.java\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`java<\/p>\n<p>public class MainActivity extends AppCompatActi<a href=\"https:\/\/www.yimenapp.net\/dabao-608.html\">ios\u95ea\u7535\u7b7e<\/a>vity {<\/p>\n<p>    private WebView mWebView;<\/p>\n<p>    @Override<\/p>\n<p>    protected void onCreate(Bundle savedInstanceState) {<\/p>\n<p>        super.onCreate(savedInstanceState<a href=\"https:\/\/www.yimenapp.net\/dabao-4006.html\">android\u5f00\u53d1jar\u5305<\/a>);<\/p>\n<p>        setContentView(R.layout.activity_main);<\/p>\n<p>        mWebView = (WebView) findViewById(R.id.w<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/31\/15\/27053424814.jpg\" \/><\/figure>\n<\/p>\n<p>ebview);<\/p>\n<p>        mWebView.loadUrl(&#8220;https:\/\/www.baidu.com&#8221;);<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5b9a\u4e49\u4e86\u4e00\u4e2aMainActivity\u7c7b\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2aWebView\u63a7\u4ef6\u7684\u5b9e\u4f8b\u3002\u5728onCreate()\u65b9\u6cd5\u4e2d\uff0c\u901a\u8fc7findViewById()\u65b9\u6cd5\u83b7\u53d6\u4e86WebView\u63a7\u4ef6\u7684\u5f15\u7528\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u5230\u6210\u5458\u53d8\u91cfmWebView\u4e2d\u3002\u7136\u540e\uff0c\u901a\u8fc7mWebView.loadUrl()\u65b9\u6cd5\u52a0\u8f7d\u4e86\u767e\u5ea6\u7f51\u9875\u3002\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u5b9e\u73b0\u3002<\/p>\n<p>4. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u4e4b\u540e\uff0c\u53ef\u4ee5\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u67e5\u770b\u7f51\u9875\u662f\u5426\u80fd\u591f\u6b63\u5e38\u52a0\u8f7d\u5e76\u663e\u793a\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u5e94\u7528\u7a0b\u5e8f\u5c06\u4f1a\u663e\u793a\u767e\u5ea6\u7f51\u9875\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u662f\u4e00\u79cd\u5c06\u7f51\u9875\u5d4c\u5165\u5230\u5b89\u5353\u5e94\u7528\u4e2d\u7684\u6280\u672f\u3002\u901a\u8fc7\u4f7f\u7528WebView\u63a7\u4ef6\uff0c\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7d\u7f51\u9875\uff0c\u5e76\u5c06\u5176\u663e\u793a\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u754c\u9762\u4e2d\u3002\u7f51\u9875\u5c01\u88c5\u5b89\u5353\u7684\u5b9e\u73b0\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u5e76\u5728Java\u4ee3\u7801\u4e2d\u52a0\u8f7d\u7f51\u9875\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f51\u9875\u5c01\u88c5\u5b89\u5353\uff0c\u4e5f\u79f0\u4e3aWebview\uff0c\u662f\u4e00\u79cd\u5728\u5b89\u5353\u5e94\u7528\u4e2d\u5d4c\u5165\u7f51\u9875\u7684\u6280\u672f\u3002\u901a\u8fc7\u4f7f\u7528Webview\u6280\u672f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5c06\u7f51\u9875\u5d4c\u5165\u5230\u5b89\u5353\u5e94\u7528\u4e2d\uff0c\u5b9e\u73b0\u539f\u751f\u5e94\u7528\u4e0e\u7f51\u9875\u7684\u65e0\u7f1d\u8854\u63a5\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u9875\u5c01\u88c5<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[29033,1775,3005,23755,1014],"class_list":["post-23781","post","type-post","status-publish","format-standard","hentry","category-appshangjia","tag-android-","tag-1775","tag-3005","tag--web-app","tag-1014"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/23781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=23781"}],"version-history":[{"count":1,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/23781\/revisions"}],"predecessor-version":[{"id":23839,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/23781\/revisions\/23839"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=23781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=23781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=23781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}