{"id":159,"date":"2018-11-17T23:30:30","date_gmt":"2018-11-17T14:30:30","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=159"},"modified":"2018-11-17T23:39:48","modified_gmt":"2018-11-17T14:39:48","slug":"%e6%89%8b%e7%95%aa%e3%81%ae%e8%a1%a8%e7%a4%ba%e3%81%a8%e7%9f%b3%e6%95%b0%e3%81%ae%e8%a1%a8%e7%a4%ba%e3%81%8c%e3%81%a7%e3%81%8d%e3%81%9f","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2018\/11\/17\/159\/","title":{"rendered":"\u624b\u756a\u306e\u8868\u793a\u3068\u77f3\u6570\u306e\u8868\u793a\u304c\u3067\u304d\u305f"},"content":{"rendered":"<p>\u7c21\u5358\u305d\u3046\u306a\u3084\u3064\u304b\u3089\u4f5c\u3063\u3066\u3053\u30fc\u3068\u601d\u3044\u3001\u624b\u756a\u3068\u77f3\u6570\u306e\u8868\u793a\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/axNljpGMaT4\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h2>\u624b\u756a\u3068\u77f3\u6570\u306e\u8868\u793a<\/h2>\n<h3>\u624b\u756a\u306e\u8868\u793a<\/h3>\n<h4>\u30b5\u30d6\u30af\u30e9\u30b9\u306b\u89aaView\u3092\u6e21\u3059<\/h4>\n<p>\u4eca\u307e\u3067onClick\u306e\u6642\u306b\u5b50View\u3092\u6e21\u3057\u3066\u3001\u5148\u306e\u95a2\u6570\u5185\u3067\u89aaView\u3092\u53d6\u5f97\u3057\u3066\u305f\u3051\u3069\u3001\u305d\u308c\u4ee5\u5916\u3067\u3082\u4f7f\u3048\u308b\u3068\u4fbf\u5229\u305d\u3046\u3060\u306a\u30fc\u3068\u8003\u3048\u8abf\u3079\u3066\u307f\u305f\u3089\u3001onCreate\u3067\u30b5\u30d6\u30af\u30e9\u30b9\u3092new\u3059\u308b\u524d\u306bfindViewById\u3067\u53d6\u5f97\u3057\u3068\u3044\u3066\u3001\u305d\u308c\u3092\u6e21\u305b\u3070\u3044\u3044\u307f\u305f\u3044\u3002<\/p>\n<p>\u306e\u3067\u3001onCreate\u3067<\/p>\n<pre>GridLayout glv = findViewById(R.id.gridLayout1);\r\nboard = new Board(context, glv);<\/pre>\n<p>\u3068\u5909\u66f4\u3057\u3001Board\u30af\u30e9\u30b9\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092<\/p>\n<pre>public Board(Context context, View v){\r\n\r\n    this.con = context;\r\n    parentView = v;<\/pre>\n<p>\u3068\u5909\u66f4\u3057\u305f\u3089\u3001parentView\u304c\u3069\u3063\u304b\u3089\u3067\u3082\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002\u3084\u3063\u305f\u306d\u3002<\/p>\n<h4>setTurn()<\/h4>\n<pre>&lt;TextView\r\n    android:id=\"@+id\/textViewTurn\"\r\n    android:layout_height=\"10dp\"\r\n    android:layout_row=\"8\"\r\n    android:layout_rowWeight=\"1\"\r\n    android:layout_column=\"0\"\r\n    android:layout_columnSpan=\"8\"\r\n    android:layout_columnWeight=\"1\"\r\n    android:layout_gravity=\"fill\"\r\n    android:layout_marginTop=\"10dp\"\r\n    android:background=\"@drawable\/tv_border\"\r\n    android:gravity=\"center\"\r\n    android:tag=\"turn\"\r\n    android:text=\"\u9ed2\u756a\u3067\u3059\"\r\n    app:autoSizeTextType=\"uniform\" \/&gt;<\/pre>\n<pre>public void setTurn(){\r\n    TextView tv = parentView.findViewWithTag(\"turn\");\r\n\r\n    switch(PlayerTurn){\r\n        case(BLACK):\r\n            tv.setText(\"\u9ed2\u756a\u3067\u3059\");\r\n            break;\r\n        case(WHITE):\r\n            tv.setText(\"\u767d\u756a\u3067\u3059\");\r\n            break;\r\n    }\r\n}<\/pre>\n<p>GridLayout\u306e\u884c\u6570\u3092\u5909\u66f4\u3057\u3066\u304b\u3089\u3001xml\u306bTextView\u3092\u8ffd\u52a0\u3002<\/p>\n<p>\u3042\u3068\u306ftag\u304b\u3089\u5f15\u3063\u5f35\u3063\u3066\u304d\u3066\u3042\u3052\u3066\u3001PlayerTurn\u306e\u5024\u3054\u3068\u306bSwitch\u3059\u308b\u3002\u3084\u3063\u3071\u7c21\u5358\u3060\u3063\u305f\u3002<\/p>\n<h3>\u77f3\u6570\u306e\u8868\u793a<\/h3>\n<p>\u77f3\u6570\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5168\u90e8\u306e\u30de\u30b9\u3092\u8abf\u3079\u3066\u9ed2\u767d\u306e\u6570\u3092\u6570\u3048\u3066\u3051\u3070\u3044\u3044\u3002\u305d\u3093\u3067\u5408\u8a08\u3092\u8868\u793a\u3059\u308c\u3070\u3044\u3044\u3002\u306f\u305a\u3002\u65b0\u305f\u306b\u77f3\u6570\u8868\u793a\u7528\u306eTextView\u3092\u4f5c\u3063\u3066\u304a\u3044\u3066\u308b\u3002<\/p>\n<h4>\u30de\u30b9\u76ee\u3092\u914d\u5217\u306b\u3076\u3063\u3053\u3080<\/h4>\n<p>\u6700\u521d\u4e00\u3064\u306e\u95a2\u6570\u3067\u5b8c\u7d50\u3055\u305b\u3088\u3046\u3068\u601d\u3063\u305f\u3051\u3069\u3001TextView\u306e\u914d\u5217\u3092\u6301\u3063\u3068\u3051\u3070\u5f8c\u3005\u4fbf\u5229\u305d\u3046\u3068\u601d\u3063\u305f\u306e\u3067\u3001\u3061\u3087\u3063\u3068\u5206\u3051\u3066\u307f\u305f\u3002<\/p>\n<p>\u30e1\u30f3\u30d0\u5909\u6570<\/p>\n<pre>TextView[][] CellArray;<\/pre>\n<p>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<\/p>\n<pre>CellArray = new TextView[8][8];\r\nscanBoard();<\/pre>\n<p>scanBoard()<\/p>\n<pre>private void scanBoard () {\r\n    for(int r = 0 ; r &lt;= 7  ; r++){\r\n        for(int c = 0 ; c &lt;= 7 ;  c++){\r\n            CellArray[r][c] = getTextViewFromTag(r, c);\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u524d\u4f5c\u3063\u305fgetTextViewFromTag()\u304c\u5f79\u306b\u7acb\u3063\u305f\u3002<\/p>\n<p>\u914d\u5217\u3067\u52d8\u9055\u3044\u3057\u3066\u305f\u3002\u914d\u5217\u306e\u8981\u7d20\u6570\u306f1\u59cb\u307e\u308a\u3060\u3051\u3069\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f0\u59cb\u307e\u308a\u306a\u306e\u306d\u3002\u6700\u521d\u306b\u8981\u7d20\u65707\u3067\u521d\u671f\u5316\u3057\u3066\u3066\u3001IndexOutOfBoundsException\u3064\u3063\u3066\u5f37\u5236\u7d42\u4e86\u3057\u3066\u305f\u3002<\/p>\n<p>\u3066\u3044\u3046\u304b\u3001\u3059\u3063\u3054\u3044\u56de\u308a\u304f\u3069\u3044\u6c17\u304c\u3059\u308b\u3002\u306a\u3093\u3060\u308d\u3046\u3053\u308c\u306f\u3001\u5408\u3063\u3066\u308b\u3093\u3060\u308d\u3046\u304b\u3002<\/p>\n<h4>\u77f3\u3092\u6570\u3048\u308b<\/h4>\n<pre>public void StoneCountOnBoard(){\r\n    BlackStoneCount = 0;\r\n    WhiteStoneCount = 0;\r\n    int color;\r\n    TextView btv = parentView.findViewById(R.id.textViewBlackStone);\r\n    TextView wtv = parentView.findViewById(R.id.textViewWhiteStone);\r\n\r\n    for(TextView[] cc : CellArray){\r\n        for(TextView c : cc){\r\n            color = getStoneColor(c);\r\n            switch(color) {\r\n                case (BLACK):\r\n                    BlackStoneCount++;\r\n                    break;\r\n                case(WHITE):\r\n                    WhiteStoneCount++;\r\n                    break;\r\n            }\r\n        }\r\n    }\r\n\r\n    btv.setText(String.valueOf(BlackStoneCount)+\"\u500b\");\r\n    wtv.setText(String.valueOf(WhiteStoneCount)+\"\u500b\");\r\n}<\/pre>\n<p>\u62e1\u5f35for\u6587\u3068\u3044\u3046\u3082\u306e\u3092\u521d\u3081\u3066\u4f7f\u3063\u305f\u3002\u6700\u521d\u30012\u6b21\u5143\u914d\u5217\u306e\u969b\u3001\u5165\u308c\u5b50\u306b\u3059\u308b\u306e\u3092\u77e5\u3089\u306a\u304f\u3066\u3001cc.getText()\u3063\u3066\u3084\u3063\u3066\u3082\u3067\u304d\u306a\u304f\u3066\u60a9\u3093\u3060\u3002\u5165\u308c\u5b50\u306b\u3059\u308b\u306e\u3068\u3001\u524d\u4f5c\u3063\u305fgetStoneColor()\u4f7f\u3048\u3070\u3044\u3093\u3058\u3083\u3093\u3063\u3066\u6c17\u3065\u3044\u305f\u306e\u3067\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u3063\u305f\u3002<\/p>\n<h3>\u3046\u30fc\u3093<\/h3>\n<p>\u30b3\u30fc\u30c9\u304c\u3054\u3061\u3083\u3054\u3061\u3083\u3057\u3066\u898b\u8f9b\u3044\u30028\u65b9\u5411\u307e\u3068\u3081\u308b\u307b\u3046\u304c\u5148\u304b\u306a\u3041\u3002<\/p>\n<h3>\u53c2\u8003<\/h3>\n<p><a href=\"http:\/\/java-lab.com\/array-multidimensional-enhanced_for\/\">http:\/\/java-lab.com\/array-multidimensional-enhanced_for\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7c21\u5358\u305d\u3046\u306a\u3084\u3064\u304b\u3089\u4f5c\u3063\u3066\u3053\u30fc\u3068\u601d\u3044\u3001\u624b\u756a\u3068\u77f3\u6570\u306e\u8868\u793a\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002 \u624b\u756a\u3068\u77f3\u6570\u306e\u8868\u793a \u624b\u756a\u306e\u8868\u793a \u30b5\u30d6\u30af\u30e9\u30b9\u306b\u89aaView\u3092\u6e21\u3059 \u4eca\u307e\u3067onClick\u306e\u6642\u306b\u5b50View\u3092\u6e21\u3057\u3066\u3001\u5148\u306e\u95a2\u6570\u5185\u3067\u89aaView\u3092\u53d6\u5f97\u3057\u3066\u305f\u3051\u3069\u3001\u305d\u308c\u4ee5 &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2018\/11\/17\/159\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[3,6,4,13],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-8","tag-android","tag-androidstudio","tag-4","tag-13"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":1,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}