質問編集履歴
3
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,11 +22,13 @@
|
|
22
22
|
|
23
23
|
```Java
|
24
24
|
|
25
|
+
//MainActivity.java
|
26
|
+
|
25
27
|
ArrayList<ListRow> list = new ArrayList<ListRow>();
|
26
28
|
|
27
29
|
for (int i = 0 ; i<10 ; i++){
|
28
30
|
|
29
|
-
list.add(new ListRow("abc","abc",10));
|
31
|
+
list.add(new ListRow("abc","abc",10)); //わかりやすいようにabcというテキストに変更
|
30
32
|
|
31
33
|
}
|
32
34
|
|
@@ -34,6 +36,136 @@
|
|
34
36
|
|
35
37
|
listView.setAdapter(adapter);
|
36
38
|
|
39
|
+
|
40
|
+
|
41
|
+
//ListRow.java
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
package com.XXX;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
public class ListRow {
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
private String a;
|
54
|
+
|
55
|
+
private String b;
|
56
|
+
|
57
|
+
private int c;
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
public ListRow(String a, String b, int c) {
|
62
|
+
|
63
|
+
this.a = a;
|
64
|
+
|
65
|
+
//同様にb,c
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
//getter setter
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//MyAdapter
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
package XXX;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
import //省略
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
public class MyAdapter extends BaseAdapter {
|
92
|
+
|
93
|
+
private LayoutInflater layoutInflater = null;
|
94
|
+
|
95
|
+
private ArrayList<ListRow> rows;
|
96
|
+
|
97
|
+
public MyAdapter(Context context) {
|
98
|
+
|
99
|
+
this.layoutInflater = LayoutInflater.from(context);
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
public void setList(ArrayList<ListRow> rows) {
|
104
|
+
|
105
|
+
this.rows = rows;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
@Override
|
110
|
+
|
111
|
+
public int getCount() {
|
112
|
+
|
113
|
+
return rows.size();
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
@Override
|
118
|
+
|
119
|
+
public Object getItem(int i) {
|
120
|
+
|
121
|
+
return rows.get(i);
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
@Override
|
126
|
+
|
127
|
+
public long getItemId(int i) {
|
128
|
+
|
129
|
+
return i;
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
@Override
|
134
|
+
|
135
|
+
public View getView(int i, View view, ViewGroup viewGroup) {
|
136
|
+
|
137
|
+
view = layoutInflater.inflate(R.layout.list_layout, viewGroup, false);
|
138
|
+
|
139
|
+
ListRow row = rows.get(i);
|
140
|
+
|
141
|
+
((TextView)view.findViewById(R.id.a)).setText(row.geta());
|
142
|
+
|
143
|
+
((TextView)view.findViewById(R.id.b)).setText(row.getb());
|
144
|
+
|
145
|
+
if (row.getProgress()==100){
|
146
|
+
|
147
|
+
((TextView)view.findViewById(R.id.c)).setVisibility(INVISIBLE);
|
148
|
+
|
149
|
+
((ProgressBar)view.findViewById(R.id.progressBar)).setVisibility(INVISIBLE);
|
150
|
+
|
151
|
+
((CheckBox)view.findViewById(R.id.checkBox)).setChecked(true);
|
152
|
+
|
153
|
+
} else {
|
154
|
+
|
155
|
+
((TextView)view.findViewById(R.id.c)).setText(row.getc()+"%");
|
156
|
+
|
157
|
+
((ProgressBar)view.findViewById(R.id.progressBar)).setProgress(row.getc());
|
158
|
+
|
159
|
+
((CheckBox)view.findViewById(R.id.checkBox)).setChecked(false);
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
return view;
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
37
169
|
```
|
38
170
|
|
39
171
|
こちらの[記事](https://symfoware.blog.fc2.com/blog-entry-2015.html)の「AdapterやLayoutを独自に実装」を参考にして作っていますので問題が発生するような特殊な方法は使っていないと思います。
|
2
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
下記の方法でスクロールしないListViewを作成しましたが、リストの項目の追加に時間がかかってしまいます。解決策はあるのでしょうか。リストの項目の追加は以下のように行っています。
|
2
2
|
|
3
3
|
https://qiita.com/osamu1203/items/a5a0c89a0437a8a00ae5
|
4
|
+
|
5
|
+
```XML
|
6
|
+
|
7
|
+
<com.example.project.NonScrollListView
|
8
|
+
|
9
|
+
android:layout_marginTop="20dp"
|
10
|
+
|
11
|
+
android:id="@+id/listView"
|
12
|
+
|
13
|
+
android:layout_width="match_parent"
|
14
|
+
|
15
|
+
android:layout_height="wrap_content"
|
16
|
+
|
17
|
+
app:layout_constraintTop_toBottomOf="@id/linearLayout" />
|
18
|
+
|
19
|
+
```
|
4
20
|
|
5
21
|
|
6
22
|
|
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,14 +8,16 @@
|
|
8
8
|
|
9
9
|
ArrayList<ListRow> list = new ArrayList<ListRow>();
|
10
10
|
|
11
|
-
|
11
|
+
for (int i = 0 ; i<10 ; i++){
|
12
12
|
|
13
|
-
|
13
|
+
list.add(new ListRow("abc","abc",10));
|
14
14
|
|
15
|
-
|
15
|
+
}
|
16
16
|
|
17
17
|
ListView listView = findViewById(R.id.listView);
|
18
18
|
|
19
|
-
|
19
|
+
listView.setAdapter(adapter);
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
こちらの[記事](https://symfoware.blog.fc2.com/blog-entry-2015.html)の「AdapterやLayoutを独自に実装」を参考にして作っていますので問題が発生するような特殊な方法は使っていないと思います。
|