質問編集履歴

3

内容の修正

2022/01/19 04:57

投稿

YonHan
YonHan

スコア40

test CHANGED
File without changes
test CHANGED
@@ -211,7 +211,7 @@
211
211
 
212
212
  ### 調べたこと
213
213
 
214
- (.)[https://stackoverflow.com/questions/37635993/could-not-find-method-onclickcreaview-in-a-parent-or-ancestor-context-for-andr]
214
+ [.](https://stackoverflow.com/questions/37635993/could-not-find-method-onclickcreaview-in-a-parent-or-ancestor-context-for-andr)
215
215
 
216
216
  ### 補足情報(FW/ツールのバージョンなど)
217
217
 

2

内容の修正

2022/01/19 04:56

投稿

YonHan
YonHan

スコア40

test CHANGED
File without changes
test CHANGED
@@ -209,9 +209,9 @@
209
209
  </LinearLayout>
210
210
  ```
211
211
 
212
- ### 試したこと
212
+ ### 調べたこと
213
-
213
+
214
- ここに問題に対して試したことを記載してください。
214
+ (.)[https://stackoverflow.com/questions/37635993/could-not-find-method-onclickcreaview-in-a-parent-or-ancestor-context-for-andr]
215
215
 
216
216
  ### 補足情報(FW/ツールのバージョンなど)
217
217
 

1

内容の修正

2022/01/19 04:30

投稿

YonHan
YonHan

スコア40

test CHANGED
File without changes
test CHANGED
@@ -128,8 +128,86 @@
128
128
  }
129
129
  }
130
130
  ```
131
+
132
+ ```ToDoAdapter
133
+ package com.example.adaptertest2;
134
+
135
+ //TODO todoテスト変更1
136
+
137
+ import android.content.Context;
138
+ import android.view.LayoutInflater;
139
+ import android.view.View;
140
+ import android.view.ViewGroup;
141
+ import android.widget.ArrayAdapter;
142
+ import android.widget.TextView;
143
+
144
+ import java.util.ArrayList;
145
+
146
+ public class ToDoAdapter extends ArrayAdapter<User> {
147
+
148
+ private LayoutInflater mInflater;
149
+ private ArrayList<User> users;
150
+ private int mViewResourceId;
151
+
152
+ public ToDoAdapter(Context context, int textViewResourceId, ArrayList<User> users) {
153
+ super(context, textViewResourceId, users);
154
+ this.users = users;
155
+ mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
156
+ mViewResourceId = textViewResourceId;
157
+ }
158
+
159
+ public View getView(int position, View convertView, ViewGroup parent) {
160
+ convertView = mInflater.inflate(mViewResourceId, null);
161
+
162
+ User user = users.get(getCount() - 1 - position);
163
+
164
+ if (user != null) {
165
+ TextView todo1Name = (TextView) convertView.findViewById(R.id.todo_title);
166
+ TextView time = (TextView) convertView.findViewById(R.id.time);
167
+ if (todo1Name != null) {
168
+ todo1Name.setText(user.getTodo1Name());
169
+ }
170
+ if (time != null) {
171
+ time.setText(user.getTime());
172
+ }
173
+ }
174
+
175
+ return convertView;
176
+ }
177
+ }
178
+ ```
179
+
180
+ ```ToDoAdapterのxml
181
+ <?xml version="1.0" encoding="utf-8"?>
182
+ <LinearLayout xmlns:android="http://s...content-available-to-author-only...d.com/apk/res/android"
183
+ android:orientation="horizontal" android:layout_width="match_parent"
184
+ android:layout_height="match_parent"
185
+ android:weightSum="100">
186
+
187
+ <TextView
188
+ android:textStyle="bold"
189
+ android:textSize="20sp"
190
+ android:layout_weight="30"
191
+ android:layout_width="match_parent"
192
+ android:layout_height="25dp"
131
- ToDoAdapter→https://www.ideone.com/zI51wS
193
+ android:id="@+id/todo_title"/>
194
+ <TextView
195
+ android:textStyle="bold"
196
+ android:textSize="20sp"
197
+ android:layout_weight="30"
198
+ android:layout_width="match_parent"
199
+ android:layout_height="25dp"
132
- ToDoAdapterのxml→https://www.ideone.com/eT13SX
200
+ android:id="@+id/time"/>
201
+
202
+ <CheckBox
203
+ android:id="@+id/todo_delete"
204
+ android:layout_width="match_parent"
205
+ android:layout_height="25dp"
206
+ android:layout_weight="39"
207
+ android:onClick="deleteTask"/>
208
+
209
+ </LinearLayout>
210
+ ```
133
211
 
134
212
  ### 試したこと
135
213