{"id":28437,"date":"2024-04-01T18:27:39","date_gmt":"2024-04-01T10:27:39","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=28437"},"modified":"2024-04-01T18:27:39","modified_gmt":"2024-04-01T10:27:39","slug":"%e7%bd%91%e9%a1%b5-%e7%94%9f%e6%88%90-%e5%ae%89%e5%8d%93app%e6%93%8d%e4%bd%9c%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2024\/28437\/","title":{"rendered":"\u7f51\u9875 \u751f\u6210 \u5b89\u5353app\u64cd\u4f5c\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"

\u6807\u9898\uff1a\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353APP\u7684\u539f\u7406\u4e0e\u8be6\u7ec6\u6559\u7a0b<\/p>\n

\u5bfc\u8bed\uff1a\u6709\u65f6\u5019\uff0c\u6211\u4eec\u5e0c\u671b\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u6216\u8005\u7f51\u9875\u5236\u4f5c\u6210\u4e00\u4e2a\u5b89\u5353APP\uff0c\u65b9\u4fbf\u7528\u6237\u8fdb\u884c\u6d4f\u89c8\u548c\u4f7f\u7528\u3002\u90a3\u4e48\u5982\u4f55\u5c06\u7f51\u9875\u8f6c\u6362\u6210\u5b89\u5353APP\u5462\uff1f\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684\u539f\u7406\u548c\u6559\u7a0b\u3002<\/p>\n

\u4e00\u3001\u539f\u7406\u7b80\u4ecb<\/p>\n

\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353APP\u7684\u4e3b\u8981\u539f\u7406\u662f\u901a\u8fc7WebView\u63a7\u4ef6\uff0c\u5c06\u7f51\u9875\u7528HTML\u3001CSS\u548cJavaScript\u6765\u8fdb\u884c\u672c\u5730\u6216\u8005\u5728\u7ebf\u5c55\u793a\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u4f60\u65e0\u9700\u4e3aAPP\u7f16\u5199\u4e00\u5957\u72ec\u7acb\u7684\u7528\u6237\u754c\u9762\uff0c\u800c\u662f\u91cd\u7528\u73b0\u6709\u7684\u7f51\u9875\u4ee3\u7801\u3002\u5b89\u5353\u4e2d\u7684WebView\u7ec4\u4ef6\u53ef\u4ee5\u5141\u8bb8\u7a0b\u5e8f\u5458\u5c06\u5176\u6dfb\u52a0\u5230\u73b0\u6709\u7684\u5b89\u5353app\u751f\u6210\u7f51\u7ad9<\/a>\u5e94\u7528\u4e2d\uff0c\u5e76\u4e14\u517c\u5bb9\u5404\u79cd\u7f51\u9875\u6280\u672f\u548c\u6846\u67b6\uff0c\u5982HTML5\u3001CSS3\u548cJavaScript\u3002<\/p>\n

\u4e8c\u3001\u8be6\u7ec6\u6559\u7a0b<\/p>\n

1. \u5b89\u88c5Android Studio<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u4e00\u4e2a\u7528\u4e8e\u5f00\u53d1\u5b89\u5353\u5e94\u7528\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u5982Android Studio\u3002\u4f60\u53ef\u4ee5\u4ecehttps:\/\/developer.android.com\/studio \u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/p>\n

2. \u521b\u5efa\u65b0\u9879\u76ee<\/p>\n

\u6253\u5f00Android Studio\uff0c\u70b9\u51fb\u201cStart a new Android Studio project\u201d\uff0c\u9009\u62e9\u201cEmpty Activity\u201d\uff0c\u70b9\u51fb\u201cNext\u201d\u3002\u5728\u9879\u76ee\u540d\u79f0\u3001\u5305\u540d\u548c\u5b58\u50a8\u4f4d\u7f6e\u7b49\u4fe1\u606f\u8fdb\u884c\u914d\u7f6e\u540e\uff0c\u70b9\u51fb\u201cFinish\u201d\u3002<\/p>\n

3. \u6dfb\u52a0WebView\u7ec4\u4ef6<\/p>\n

\u5728\u9879\u76ee\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u201cactivity_main.xml\u201d\u3002\u5220\u9664\u5df2\u6709\u7684\u201cHello World!\u201d\u6587\u672c\u7ec4\u4ef6\uff0c\u5e76\u5728\u8be5\u5e03\u5c40\u6587\u4ef6\u4e2d\u6dfb\u52a0WebView\u7ec4\u4ef6\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/webview”<\/p>\n

android:layout_width=”match_parent”<\/p>\n

android:layout_height=”match_parent”<\/p>\n

android:layout_alignParentTop=”true”<\/p>\n

android:layout_alignParentLeft=”true”<\/p>\n

android:layout_alignParentStart=”true”<\/p>\n

xmlns:android=”http:\/\/schemas.android.com\/apk\/res\/android” \/><\/p>\n

“`<\/p>\n

4. \u5728MainActivity\u4e2d\u52a0\u8f7d\u7f51\u9875<\/p>\n

\u6253\u5f00\u201cMainActivity.java\u201d\u6587\u4ef6\uff0c\u9996\u5148\u5bfc\u5165WebView\u548cWebSettings\u5305\uff1a<\/p>\n

“`java<\/p>\n

import android.webkit.WebSettings;<\/p>\n

import android.webkit.WebView;<\/p>\n

“`<\/p>\n

\u63a5\u7740\uff0c\u5728\u201conCreate\u201d\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`java<\/p>\n

WebView webView = findViewById(R.id.webview);<\/p>\n

WebSettings webSettings = webView.getSettings();<\/p>\n

\/\/ \u542f\u7528JavaScript\u652f\u6301<\/p>\n

webSettings.setJavaScriptEnabled(true);<\/p>\n

\/\/\u8bbe\u7f6e\u662f\u5426\u652f\u6301\u7f29\u653e<\/p>\n

webSettings.setSupportZoom(true);<\/p>\n

\/\/ \u52a0\u8f7d\u7f51\u9875<\/p>\n

webView.loadUrl(“https:\/\/yourwebsite.com”);<\/p>\n

“`<\/p>\n

\u6ce8\u610f\u5c06\u201chttps:\/\/yourwebsite.com\u201d\u66ff\u6362\u4e3a\u4f60\u81ea\u5df1\u9700\u8981\u5c55\u793a\u7684\u7f51\u7ad9\u5730\u5740\u3002<\/p>\n

5. \u6dfb\u52a0\u7f51\u7edc\u6743\u9650\u548c\u786c\u4ef6\u52a0\u901f<\/p>\n

\u5728\u201cAndroidManifest.xml\u201d\u4e2d\uff0c\u52a0\u5165\u7f51\u7edc\u6743\u9650\uff0c\u4ee5\u4fbf\u4f60\u7684APP\u53ef\u4ee5\u8bbf\u95ee\u4e92\u8054\u7f51\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

“`<\/p>\n

\u4e3a\u4e86\u63d0\u9ad8WebView\u7684\u6e32\u67d3\u6027\u80fd\uff0c\u9700\u8981\u542f\u7528\u786c\u4ef6\u52a0\u901f\u3002\u5728\u201cAndroidManifest.xml\u201d\u7684 \u201c\u201d\u6807\u7b7e\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5c5e\u6027\uff1a<\/p>\n

“`xml<\/p>\n

android:hardwareAccelerated=”true”<\/p>\n

“`<\/p>\n

6. \u7f16\u8bd1\u5e76\u8fd0\u884cAPP<\/p>\n

\u70b9\u51fbAn\u7f51\u9875\u751f\u6210app\u4f1a\u88ab\u6295\u8bc9\u5417<\/a>droid Studio\u9876\u90e8\u5de5\u5177\u680f\u7684\u8fd0\u884c\u6309\u94ae\uff08\u7eff\u8272\u4e09\u89d2\u5f62\uff09\u6216\u6309\u4e0bShif<\/p>\n

<\/figure>\n<\/p>\n

t + F10\uff0c\u9009\u62e9\u6a21\u62df\u5668\u6216\u8fde\u63a5\u7684\u771f\u5b9e\u8bbe\u5907\u8fdb\u884c\u8fd0\u884c\uff0c\u67e5\u770b\u4f60\u7684\u7f51\u9875\u662f\u5426\u5df2\u7ecf\u6210\u529f\u8f6c\u6362\u6210\u5b89\u5353APP\u3002<\/p>\n

\u4e09\u3001\u603b\u7ed3<\/p>\n

\u901a\u8fc7\u4e0a\u8ff0\u6559\u7a0b\uff0c\u76f8\u4fe1\u5927\u5bb6\u5df2\u7ecf\u638c\u63e1\u4e86\u5982\u4f55\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353APP\u7684\u65b9\u6cd5\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u6613\u884c\uff0c\u9002\u5408\u4e92\u8054\u7f51\u4ece\u4e1a\u8005\u5bf9\u7f51\u7ad9\u548c\u7f51\u9875\u8fdb\u884c\u5feb\u901f\u79fb\u52a8\u7aef\u9002\u914d\u3002\u5f53\u7136\uff0cWebView\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\uff0c\u4f8b\u5982\u6027\u80fd\u548c\u517c\u5bb9\u6027\u7b49\u7b49\uff0c\u53ef\u80fd\u9700\u8981\u9488\u5bf9\u5177\u4f53\u9700\u6c42\u8fdb\u884c\u66f4\u591a\u5b9a\u5236\u5316\u5f00\u53d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6807\u9898\uff1a\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353APP\u7684\u539f\u7406\u4e0e\u8be6\u7ec6\u6559\u7a0b\u5bfc\u8bed\uff1a\u6709\u65f6\u5019\uff0c\u6211\u4eec\u5e0c\u671b\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u6216\u8005\u7f51\u9875\u5236\u4f5c\u6210\u4e00\u4e2a\u5b89\u5353APP\uff0c\u65b9\u4fbf\u7528\u6237\u8fdb\u884c\u6d4f\u89c8\u548c\u4f7f\u7528\u3002\u90a3\u4e48\u5982\u4f55\u5c06\u7f51\u9875\u8f6c\u6362\u6210\u5b89\u5353APP\u5462\uff1f\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684\u539f\u7406\u548c\u6559<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[29611,914,117,12118,261],"class_list":{"0":"post-28437","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-zuoapp","7":"tag-app","8":"tag-914","9":"tag-117","11":"tag-261"},"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=28437"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28437\/revisions"}],"predecessor-version":[{"id":28512,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28437\/revisions\/28512"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=28437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=28437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=28437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}