{"id":1613,"date":"2017-09-12T17:23:52","date_gmt":"2017-09-12T08:23:52","guid":{"rendered":"http:\/\/kuuur.net\/?p=1613"},"modified":"2017-09-12T17:23:52","modified_gmt":"2017-09-12T08:23:52","slug":"tap","status":"publish","type":"post","link":"https:\/\/kuuur.net\/?p=1613","title":{"rendered":"Android\u30a2\u30d7\u30ea\uff1a\u753b\u9762\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u308b"},"content":{"rendered":"<p>\u753b\u9762\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u308b\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u8abf\u3079\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u30ec\u30a4\u30a2\u30a6\u30c8\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3092\u300cactivity_main.xml\u300d\u3001<br \/>\n\u30d7\u30ed\u30b0\u30e9\u30e0\u30d5\u30a1\u30a4\u30eb\u3092\u300cMainActivity.java\u300d\u3068\u3057\u307e\u3059\u3002<\/p>\n<h2>\u90e8\u54c1\u306e\u914d\u7f6e<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1614\" src=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap01.jpg\" alt=\"\" width=\"650\" height=\"493\" srcset=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap01.jpg 650w, https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap01-300x228.jpg 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>\u300cactivity_main.xml\u300d\u3092\u300cDesign\u300d\u30bf\u30d6\u3067\u958b\u304d\u3001Pallet\u304b\u3089\u300cTextView\u300d\u30921\u3064\u30c9\u30e9\u30c3\u30b0\u3057\u307e\u3059\u3002<br \/>\nTextView\u306eID\u3092\u300ctextView\u300d\u306b\u3057\u3066\u3001\u753b\u9762\u306e\u4e2d\u592e\u306b\u8868\u793a\u3059\u308b\u305f\u3081\u3001\u300cCenter Horizontally\u300d\u3068\u300cCenter Vertically\u300d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1615\" src=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap02.jpg\" alt=\"\" width=\"514\" height=\"794\" srcset=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap02.jpg 514w, https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap02-194x300.jpg 194w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><\/p>\n<p>\u4eca\u56de\u306f\u3001TextView\u3092\u6271\u3046\u306e\u3068\u540c\u6642\u306b\u3001\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u3082\u6271\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001\u6700\u521d\u306bimport\u6587\u3067\u3001\u4ee5\u4e0b\u306e2\u6587\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p class=\"source\">import android.view.MotionEvent;<br \/>\nimport android.widget.TextView;<\/p>\n<p>\u306a\u304a\u3001import\u6587\u306f\u3001TextView\u3084MotionEvent\u3092\u5165\u529b\u3057\u305f\u969b\u306b\u3001Alt\u30ad\u30fc\uff0bEnter\u3092\u62bc\u3059\u3068\u81ea\u52d5\u7684\u306b\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u5f8c\u306f\u3001public class MainActivity extends AppCompatActivity {}\u5185\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u5909\u6570\u3092\u5148\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p class=\"source\">String str;<br \/>\nString str2;<br \/>\nprivate TextView textView;<\/p>\n<p>str\u306f\u5f8c\u8ff0\u3057\u307e\u3059\u304c\u3001\u30bf\u30c3\u30d7\u3055\u308c\u305f\u5f8c\u306b\u8868\u793a\u3055\u305b\u308b\u3001\u300cTouched!\u300d\u3068\u3044\u3046\u6587\u5b57\u5217\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<p>str2\u306f\u3001\u73fe\u5728\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<p>textView\u306f\u3001\u753b\u9762\u4e0a\u306e\u30c6\u30ad\u30b9\u30c8\u3078\u306e\u53c2\u7167\u3067\u3059\u3002<\/p>\n<p class=\"source\">public boolean onTouchEvent(MotionEvent event){<br \/>\nTextView textView = (TextView)findViewById(R.id.textView);<br \/>\nString tv = textView.getText().toString();<br \/>\nstr=&#8221;Touched!&#8221;;<br \/>\nif (tv == str){<br \/>\nstr2=&#8221;UnTouched&#8230;&#8221;;<br \/>\n}<br \/>\nelse{<br \/>\nstr2=str;<br \/>\n}<br \/>\nswitch (event.getAction()){<br \/>\ncase MotionEvent.ACTION_UP:<br \/>\ntextView.setText(str2);<br \/>\n}<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>public boolean onTouchEvent(MotionEvent event){}<br \/>\n\u3068\u306f\u3001boolean\u578b\uff08\u30d6\u30fc\u30ea\u30a2\u30f3\u578b\uff09\u3092\u8fd4\u3059\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<br \/>\nboolean\u578b\u3068\u306f\u3001True\u53c8\u306fFalse\u306e\u3044\u305a\u308c\u304b\u306e\u5024\u3092\u8fd4\u3059\u578b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>TextView textView = (TextView)findViewById(R.id.textView);<br \/>\n\u3067\u306f\u3001\u753b\u9762\u4e0a\u306etextView\u3078\u306e\u53c2\u7167\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>String tv = textView.getText().toString();<br \/>\n\u3067\u306f\u3001tv\u306btextView\u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u5185\u5bb9\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u683c\u7d0d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>if (tv == str){<br \/>\nstr2=&#8221;UnTouched&#8230;&#8221;;<br \/>\n}<br \/>\nelse{<br \/>\nstr2=str;<br \/>\n}<br \/>\n\u3067\u306f\u3001textView\u306e\u5185\u5bb9\u304c\u300cTouched!\u300d\u3067\u3042\u308c\u3070\u3001str2\u306e\u5185\u5bb9\u3092\u300cUntouched&#8230;\u300d\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3046\u3067\u306a\u3051\u308c\u3070\u300cTouched!\u300d\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>switch (event.getAction()){<br \/>\ncase MotionEvent.ACTION_UP:<br \/>\ntextView.setText(str2);<br \/>\n}<br \/>\n\u3067\u306f\u3001\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u306e\u3046\u3061\u3001\u30bf\u30c3\u30c1\u3057\u305f\u6307\u304c\u4e0a\u304c\u3063\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u306b\u306f\u3053\u306e\u307b\u304b\u3001\u89e6\u3063\u3066\u3044\u308b\u6642\u306b\u767a\u751f\u3059\u308b\u3082\u306e\u3084\u30bf\u30c3\u30c1\u3057\u305f\u307e\u307e\u79fb\u52d5\u3057\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u3082\u306e\u306a\u3069\u3001\u69d8\u3005\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u30bf\u30c3\u30c1\u3057\u305f\u6307\u304c\u4e0a\u304c\u3063\u305f\u3068\u304d\u4ee5\u5916\u306e\u30a4\u30d9\u30f3\u30c8\u306f\u4e0d\u8981\u306a\u306e\u3067\u66f8\u3044\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>return false;<br \/>\nboolean\u578b\u306f\u5fc5\u305atrue\u304bfalse\u3067\u5024\u3092\u623b\u3055\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>\u5b9f\u969b\u306e\u52d5\u4f5c<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1616\" src=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap03.jpg\" alt=\"\" width=\"300\" height=\"552\" srcset=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap03.jpg 300w, https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap03-163x300.jpg 163w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u6700\u521d\u306f\u300cTextView\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u753b\u9762\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3068&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1617\" src=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap04.jpg\" alt=\"\" width=\"300\" height=\"552\" srcset=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap04.jpg 300w, https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap04-163x300.jpg 163w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u300cTouched!\u300d\u306b\u5909\u308f\u308a\u307e\u3059\u3002<br \/>\n\u3055\u3089\u306b\u30bf\u30c3\u30d7\u3059\u308b\u3068&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1618\" src=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap05.jpg\" alt=\"\" width=\"300\" height=\"552\" srcset=\"https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap05.jpg 300w, https:\/\/kuuur.net\/wp-content\/uploads\/2017\/09\/tap05-163x300.jpg 163w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u300cUnTouched&#8230;\u300d\u306b\u5909\u308f\u308a\u307e\u3059\u3002<br \/>\n\u4ee5\u964d\u306f\u30bf\u30c3\u30d7\u3059\u308b\u3054\u3068\u306b\u300cTouched\u300d\u3068\u300cUnTouched\u300d\u3092\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u753b\u9762\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u308b\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308a\u307e\u3059\u3002 \u4eca\u56de\u306f\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u8abf\u3079\u307e\u3057\u305f\u3002 \u3053\u3053\u3067\u306f\u30ec\u30a4\u30a2\u30a6\u30c8\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3092\u300cactivity_main.xml\u300d\u3001 \u30d7\u30ed\u30b0\u30e9\u30e0\u30d5\u30a1\u30a4\u30eb\u3092&#8230;<span class=\"continue\"><a href=\"https:\/\/kuuur.net\/?p=1613\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-1613","post","type-post","status-publish","format-standard","hentry","category-android"],"views":9997,"_links":{"self":[{"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/posts\/1613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kuuur.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1613"}],"version-history":[{"count":2,"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions"}],"predecessor-version":[{"id":1620,"href":"https:\/\/kuuur.net\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions\/1620"}],"wp:attachment":[{"href":"https:\/\/kuuur.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kuuur.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kuuur.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}