質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
コード
|
1
|
-
androidstudio, javaで簡単な家計簿アプリを作成しています。
|
3
|
+
```androidstudio, javaで簡単な家計簿アプリを作成しています。
|
2
4
|
|
3
5
|
実現したいこと
|
4
6
|
リストビューで一番右に表示した金額の合計を下に表示したい
|
@@ -278,3 +280,42 @@
|
|
278
280
|
}
|
279
281
|
}
|
280
282
|
```
|
283
|
+
|
284
|
+
|
285
|
+
MainListAdapter.java
|
286
|
+
```ここに言語を入力
|
287
|
+
package com.example.databasetest;
|
288
|
+
|
289
|
+
import android.content.Context;
|
290
|
+
import android.database.Cursor;
|
291
|
+
import android.view.View;
|
292
|
+
import android.view.ViewGroup;
|
293
|
+
import android.widget.Button;
|
294
|
+
import android.widget.ImageButton;
|
295
|
+
import android.widget.SimpleCursorAdapter;
|
296
|
+
|
297
|
+
public class MainListAdapter extends SimpleCursorAdapter {
|
298
|
+
|
299
|
+
// コンストラクタ
|
300
|
+
public MainListAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
301
|
+
super(context, layout, c, from, to, flags);
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
// 指定データのビューを取得
|
307
|
+
@Override
|
308
|
+
public View getView(int position, View convertView, ViewGroup parent) {
|
309
|
+
View view = super.getView(position, convertView, parent);
|
310
|
+
|
311
|
+
// 削除ボタン オブジェクトを取得
|
312
|
+
Button btnDel = (Button) view.findViewById(R.id.button_delete);
|
313
|
+
|
314
|
+
// ボタンにリスト内の位置を設定
|
315
|
+
btnDel.setTag(position);
|
316
|
+
|
317
|
+
return view;
|
318
|
+
}
|
319
|
+
|
320
|
+
}
|
321
|
+
```
|