case 1 : How to get selected child in GridLayout similar to GridView
case 2 : Set rowSpan or colSpan of a child of a GridLayout programmatically?
How to get selected child in GridLayout similar to GridView
I want to achieve the following abilities: Select only one child View inside a GridLayout each time by long clicking it. A click on the GridLayout or any ancestor parent in the visual hierarchy will
stackoverflow.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | //ポイント位置の初期設定のため public void setPointLocation(Point p){ int row = Integer.parseInt(p.getPosition()) % 10 - 1; int col = Integer.parseInt(p.getPosition()) / 10 - 1; //表示位置デザイン View grid = findViewById(btn[row][col].getId()); GridLayout.LayoutParams params = new GridLayout.LayoutParams(grid.getLayoutParams()); params.rowSpec = GridLayout.spec(row,2); params.columnSpec = GridLayout.spec(col,2); params.setGravity(Gravity.FILL); grid.setLayoutParams(params); grid.setVisibility(View.VISIBLE); //表示名デザイン Button mBtn = btn[row][col]; mBtn.setTextColor(Color.WHITE); mBtn.setText(p.getPointNum()); mBtn.setGravity(Gravity.LEFT|Gravity.TOP); mBtn.setTextSize(32); mBtn.setTypeface(null, Typeface.BOLD); mBtn.setPadding(15,0,0,0); mBtn.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); } | cs |
'Android' 카테고리의 다른 글
1차 작성 (0) | 2020.07.10 |
---|---|
XML Parsing (0) | 2020.07.08 |
레이아웃 작성 레퍼런스 (0) | 2020.07.03 |
C#서버와 안드로이드 통신 처리 참고 자료 (0) | 2020.07.02 |
프로젝트 착수 전 참고 (0) | 2020.07.01 |
댓글