質問編集履歴
2
解決方法を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -165,3 +165,15 @@
|
|
165
165
|
}
|
166
166
|
|
167
167
|
```
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
解決方法(2017/06/23追記)
|
172
|
+
|
173
|
+
-
|
174
|
+
|
175
|
+
- TextViewにView#setTagでタグを設定
|
176
|
+
|
177
|
+
- タグにレコードのコラムを設定
|
178
|
+
|
179
|
+
- ContextMenu#addでタグを取得
|
1
コードを修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,18 +36,132 @@
|
|
36
36
|
|
37
37
|
-
|
38
38
|
|
39
|
-
|
39
|
+
BaseActivity.java
|
40
40
|
|
41
|
+
```java
|
42
|
+
|
43
|
+
//データベースを表示
|
44
|
+
|
41
|
-
|
45
|
+
Cursor c = db.query(tb_name, new String[]{MyDBHelper.TASK_COL, },
|
46
|
+
|
47
|
+
null, null, null, null, null);
|
48
|
+
|
49
|
+
Boolean bool = c.moveToFirst();
|
50
|
+
|
51
|
+
while(bool){
|
52
|
+
|
53
|
+
//テキストビューを設定
|
54
|
+
|
55
|
+
TextView tv = new TextView(this);
|
56
|
+
|
57
|
+
tv.setText(c.getString(0));
|
42
58
|
|
43
59
|
|
44
60
|
|
45
|
-
|
61
|
+
//TextViewの見た目の設定
|
46
62
|
|
63
|
+
if(Build.VERSION.SDK_INT < 23){
|
64
|
+
|
47
|
-
|
65
|
+
tv.setTextAppearance(this, R.style.TextAppearance_AppCompat_Medium);
|
66
|
+
|
67
|
+
} else {
|
68
|
+
|
69
|
+
tv.setTextAppearance(R.style.TextAppearance_AppCompat_Medium);
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
tv.setBackgroundColor(Color.parseColor("#FFD740"));
|
74
|
+
|
75
|
+
tv.setPadding(20,10,20,10);
|
76
|
+
|
77
|
+
LinearLayout.LayoutParams tv_params = new LinearLayout.LayoutParams(
|
78
|
+
|
79
|
+
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
80
|
+
|
81
|
+
tv_params.setMargins(0,0,0,40);
|
82
|
+
|
83
|
+
tv.setLayoutParams(tv_params);
|
48
84
|
|
49
85
|
|
50
86
|
|
51
|
-
|
87
|
+
//ContextMenuの登録
|
52
88
|
|
89
|
+
registerForContextMenu(tv);
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
layout.addView(tv);
|
94
|
+
|
95
|
+
bool = c.moveToNext();
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
c.close();
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
//ContextMenuの設定
|
106
|
+
|
107
|
+
@Override
|
108
|
+
|
53
|
-
|
109
|
+
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
110
|
+
|
111
|
+
super.onCreateContextMenu(menu, v, menuInfo);
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
//Menuに項目を追加
|
116
|
+
|
117
|
+
menu.add("edit");
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
@Override
|
126
|
+
|
127
|
+
public boolean onContextItemSelected(MenuItem item) {
|
128
|
+
|
129
|
+
//TODO: edit画面への遷移
|
130
|
+
|
131
|
+
Intent intent = new Intent(this, EditActivity.class);
|
132
|
+
|
133
|
+
//TODO: クリックしたタスクのIDを取得
|
134
|
+
|
135
|
+
intent.putExtra("id_intent", 0);
|
136
|
+
|
137
|
+
startActivity(intent);
|
138
|
+
|
139
|
+
return super.onContextItemSelected(item);
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
MainActivity.java
|
148
|
+
|
149
|
+
```java
|
150
|
+
|
151
|
+
protected void onResume() {
|
152
|
+
|
153
|
+
super.onResume();
|
154
|
+
|
155
|
+
//TBを更新
|
156
|
+
|
157
|
+
refreshTB(tb_name);
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
//TBを表示
|
162
|
+
|
163
|
+
showTB(layout, tb_name);
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
```
|