APP<\/a>g.valueOf(result), Toast.LENGTH_SHORT).show();<\/p>\n }<\/p>\n
});<\/p>\n
buttonSub.setOnClickListener(new View.OnClickListener() {<\/p>\n
@Override<\/p>\n
public void onClick(View v) {<\/p>\n
int num1 = Integer.parseInt(editText1.getText().toString());<\/p>\n
int num2 = Integer.parseInt(editText2.getText().toString());<\/p>\n
int result = num1 – num2;<\/p>\n
Toast.makeText(MainActivity.this, String.valueOf(result), Toast.LENGTH_SHORT).show();<\/p>\n
}<\/p>\n
});<\/p>\n
buttonMul.setOnClickListener(new View.OnClickListener() {<\/p>\n
@Override<\/p>\n
public void onClick(View v) {<\/p>\n
int num1 = Integer.parseInt(editText1.getText().toString());<\/p>\n
int num2 = Integer.parseInt(editText2.getText().toString());<\/p>\n
int result = num1 * num2;<\/p>\n
Toast.makeText(MainActivity.this, String.valueOf(result), Toast.LENGTH_SHORT).show();<\/p>\n
}<\/p>\n
});<\/p>\n
buttonDiv.setOnClickListener(new View.OnClickListener() {<\/p>\n
@Override<\/p>\n
public void onClick(View v) {<\/p>\n
int num1 = Integer.parseInt(editText1.getText().toString());<\/p>\n
int num2 = Integer.parseInt(editText2.getText().toString());<\/p>\n
int result = num1 \/ num2;<\/p>\n
Toast.makeText(MainActivity.this, String.valueOf(result), Toast.LENGTH_SHORT).show();<\/p>\n
}<\/p>\n
}<\/p>\n
<\/figure>\n<\/p>\n);<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 OnClickListener \u63a5\u53e3\u6765\u5b9e\u73b0\u56db\u4e2a\u6309\u94ae\u7684\u70b9\u51fb\u64cd\u4f5c\uff0c\u4f7f\u7528\u4e86 EditText \u4e2d\u7684 getText() \u65b9\u6cd5\u6765\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\uff0c\u4f7f\u7528\u4e86 Toast \u6765\u5c55\u793a\u8ba1\u7b97\u7ed3\u679c\u3002<\/p>\n
3. \u8fd0\u884cAPP\u3002\u6700\u540e\uff0c\u5728 Android Studio \u4e2d\u7f16\u8bd1\u5e76\u8fd0\u884c\u4ee3\u7801\uff0c\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u7b97\u5668APP\u3002\u4f60\u53ef\u4ee5\u8f93\u5165\u6570\u5b57\u548c\u64cd\u4f5c\u7b26\uff0c\u7136\u540e\u70b9\u51fb\u64cd\u4f5c\u7b26\u6309\u94ae\u6765\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n
\u4ee5\u4e0a\u4fbf\u662f\u4e00\u4e2a\u7b80\u5355\u7684APP\u5f00\u53d1\u5b9e\u73b0\u793a\u4f8b\u3002\u5728\u5b9e\u9645APP\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9700\u8981\u66f4\u52a0\u590d\u6742\u7684\u4ee3\u7801\u548c\u529f\u80fd\uff0c\u4f46\u4ee5\u4e0a\u7684\u8fc7\u7a0b\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u521d\u6b65\u4e86\u89e3APP\u5f00\u53d1\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u4ee5\u540e\u8fdb\u884c\u66f4\u52a0\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u73b0\u4eca\uff0c\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\uff08APP\uff09\u8d8a\u6765\u8d8a\u6d41\u884c\uff0c\u800cAPP\u5f00\u53d1\u8005\u4e5f\u8d8a\u6765\u8d8a\u591a\u3002\u90a3\u4e48APP\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u5462\uff1f\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684APP\u5b9e\u73b0\u4ee3\u7801\u8303\u4f8b\u3002\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u7b97\u5668APP\u4e3a\u4f8b\uff0c\u6765\u4ecb\u7ecdAPP\u5f00\u53d1\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002\u6211<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3002,4578,38,6106,2267],"topic":[],"class_list":["post-9419","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-html","tag-webapp","tag-38","tag-6106","tag-2267"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/9419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=9419"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/9419\/revisions"}],"predecessor-version":[{"id":9447,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/9419\/revisions\/9447"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=9419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=9419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=9419"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=9419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}