{"id":48469,"date":"2024-12-02T08:04:14","date_gmt":"2024-12-02T00:04:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48469\/"},"modified":"2024-12-02T08:04:14","modified_gmt":"2024-12-02T00:04:14","slug":"android-%e6%8c%89%e9%92%ae%e5%8d%95%e5%87%bb%e4%ba%8b%e4%bb%b6%e5%a6%82%e4%bd%95%e5%bc%b9%e5%87%ba-hello-world-%e5%af%b9%e8%af%9d%e6%a1%86%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48469\/","title":{"rendered":"Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f<\/h1>\n<p>\u54c8\u55bd\uff01\u4eca\u5929\u5fc3\u8840\u6765\u6f6e\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aAndroid \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u300b<\/span>\uff0c\u60f3\u5fc5\u5927\u5bb6\u5e94\u8be5\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u90fd\u4e0d\u964c\u751f\u5427\uff0c\u90a3\u4e48\u9605\u8bfb\u672c\u6587\u5c31\u90fd\u4e0d\u4f1a\u5f88\u56f0\u96be\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5343\u4e07\u522b\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u4f60\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241109\/1731152552672f4aa8a7e06.jpg\" class=\"aligncenter\" title=\"Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u63d2\u56fe\" alt=\"Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6dfb\u52a0 android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u4f60\u63d0\u4f9b\u4e86 android \u5e94\u7528\u6e90\u4ee3\u7801\u7684\u94fe\u63a5\uff0c\u4f46\u5728\u5176\u4e2d\u4e00\u4e2a\u7247\u6bb5 xml \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e86\u4e00\u4e2a\u6309\u94ae\uff0c\u4f46\u5355\u51fb\u4e8b\u4ef6\u51fa\u9519\u3002\u4f60\u9700\u8981\u5e2e\u52a9\u6dfb\u52a0\u4e00\u4e2a\u5355\u51fb\u4e8b\u4ef6\uff0c\u4ee5\u4fbf\u5728\u5355\u51fb\u6309\u94ae\u65f6\u5f39\u51fa &#8220;hello world&#8221; \u5bf9\u8bdd\u6846\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u63d0\u4f9b\u7684\u6e90\u7801\u6587\u4ef6\u5df2\u7ecf\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u65e0\u6cd5\u6839\u636e\u63d0\u4f9b\u7684\u4e0a\u4e0b\u6587\u63d0\u4f9b\u786e\u5207\u7684\u6307\u5bfc\u3002\u4f46\u662f\uff0c\u4ee5\u4e0b\u662f\u6dfb\u52a0 android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u7684\u901a\u7528\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u5728\u4f60\u7684\u5e03\u5c40 xml \u6587\u4ef6\u4e2d\u627e\u5230\u6309\u94ae\u5143\u7d20\u3002<\/li>\n<li>\u6dfb\u52a0 android:onclick \u5c5e\u6027\uff0c\u5e76\u5c06\u5176\u503c\u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u5305\u542b\u4e8b\u4ef6\u5904\u7406\u5668\u7684\u7c7b\u548c\u65b9\u6cd5\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5728\u4f60\u7684\u6d3b\u52a8\u6216\u8005\u7247\u6bb5\u7c7b\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5728\u6309\u94ae\u5355\u51fb\u65f6\u6267\u884c\u3002<\/li>\n<li>\u5728\u65b9\u6cd5\u4e2d\uff0c\u4f7f\u7528 toast.maketext() \u65b9\u6cd5\u663e\u793a &#8220;hello world&#8221; \u6d88\u606f\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<p><strong>\u5e03\u5c40 xml \u6587\u4ef6\uff1a<\/strong><\/p>\n<pre>&lt;button\n    android:id=\"@+id\/my_button\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:text=\"click me\"\n    android:onclick=\"onclickbutton\" \/&gt;<\/pre>\n<p><strong>\u6d3b\u52a8\u6216\u8005\u7247\u6bb5\u7c7b\uff1a<\/strong><\/p>\n<pre>public class MyActivity extends Activity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.my_layout);\n\n        Button myButton = (Button) findViewById(R.id.my_button);\n        myButton.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View view) {\n                Toast.makeText(MyActivity.this, \"Hello World\", Toast.LENGTH_SHORT).show();\n            }\n        });\n    }\n}<\/pre>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aAndroid \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f \u54c8\u55bd\uff01\u4eca\u5929\u5fc3\u8840\u6765\u6f6e\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u300aAndroid \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u300b\uff0c\u60f3\u5fc5\u5927\u5bb6\u5e94\u8be5\u5bf9\u6587\u7ae0\u90fd\u4e0d\u964c\u751f\u5427\uff0c\u90a3\u4e48\u9605\u8bfb\u672c\u6587\u5c31\u90fd\u4e0d\u4f1a\u5f88\u56f0\u96be\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u82e5\u662f\u4f60\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\uff0c\u5343\u4e07\u522b\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u4f60\uff01 \u6dfb\u52a0 android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6 \u95ee\u9898\u63cf\u8ff0\uff1a \u4f60\u63d0\u4f9b\u4e86 android \u5e94\u7528\u6e90\u4ee3\u7801\u7684\u94fe\u63a5\uff0c\u4f46\u5728\u5176\u4e2d\u4e00\u4e2a\u7247\u6bb5 xml \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e86\u4e00\u4e2a\u6309\u94ae\uff0c\u4f46\u5355\u51fb\u4e8b\u4ef6\u51fa\u9519\u3002\u4f60\u9700\u8981\u5e2e\u52a9\u6dfb\u52a0\u4e00\u4e2a\u5355\u51fb\u4e8b\u4ef6\uff0c\u4ee5\u4fbf\u5728\u5355\u51fb\u6309\u94ae\u65f6\u5f39\u51fa &#8220;hello world&#8221; \u5bf9\u8bdd\u6846\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u63d0\u4f9b\u7684\u6e90\u7801\u6587\u4ef6\u5df2\u7ecf\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u65e0\u6cd5\u6839\u636e\u63d0\u4f9b\u7684\u4e0a\u4e0b\u6587\u63d0\u4f9b\u786e\u5207\u7684\u6307\u5bfc\u3002\u4f46\u662f\uff0c\u4ee5\u4e0b\u662f\u6dfb\u52a0 android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u7684\u901a\u7528\u6b65\u9aa4\uff1a \u5728\u4f60\u7684\u5e03\u5c40 xml \u6587\u4ef6\u4e2d\u627e\u5230\u6309\u94ae\u5143\u7d20\u3002 \u6dfb\u52a0 android:onclick \u5c5e\u6027\uff0c\u5e76\u5c06\u5176\u503c\u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u5305\u542b\u4e8b\u4ef6\u5904\u7406\u5668\u7684\u7c7b\u548c\u65b9\u6cd5\u7684\u5b57\u7b26\u4e32\u3002 \u5728\u4f60\u7684\u6d3b\u52a8\u6216\u8005\u7247\u6bb5\u7c7b\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5728\u6309\u94ae\u5355\u51fb\u65f6\u6267\u884c\u3002 \u5728\u65b9\u6cd5\u4e2d\uff0c\u4f7f\u7528 toast.maketext() \u65b9\u6cd5\u663e\u793a &#8220;hello world&#8221; \u6d88\u606f\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a \u5e03\u5c40 xml \u6587\u4ef6\uff1a &lt;button android:id=&#8221;@+id\/my_button&#8221; android:layout_width=&#8221;wrap_content&#8221; android:layout_height=&#8221;wrap_content&#8221; android:text=&#8221;click me&#8221; android:onclick=&#8221;onclickbutton&#8221; \/&gt; \u6d3b\u52a8\u6216\u8005\u7247\u6bb5\u7c7b\uff1a public class MyActivity [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48469","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48469"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48469\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}