{"id":65085,"date":"2025-05-03T16:47:35","date_gmt":"2025-05-03T08:47:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65085\/"},"modified":"2025-05-03T16:47:35","modified_gmt":"2025-05-03T08:47:35","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-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65085\/","title":{"rendered":"Android \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173111833274360.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\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fAndroid \u6309\u94ae\u5355\u51fb\u4e8b\u4ef6\u5982\u4f55\u5f39\u51fa &#8220;Hello World&#8221; \u5bf9\u8bdd\u6846\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\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\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; \u767b\u5f55\u540e\u590d\u5236 \u6d3b\u52a8\u6216\u8005\u7247\u6bb5\u7c7b\uff1a public class MyActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { [&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-65085","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65085","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=65085"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65085\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}