質問編集履歴

7

ついか 

2017/05/09 03:09

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -148,6 +148,10 @@
148
148
 
149
149
 
150
150
 
151
+ //本来は、ListViewをScrollViewで囲っているのに、それを記載していませんでした。そして、ScrollViewで囲っていることが原因でした。すみません。
152
+
153
+
154
+
151
155
  ```xml
152
156
 
153
157
  //----------------------------------------------------ListViewのxml------------------------------------------------------//

6

わかりやすく修正

2017/05/09 03:09

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -146,21 +146,13 @@
146
146
 
147
147
  ```
148
148
 
149
+
150
+
149
151
  ```xml
150
152
 
151
153
  //----------------------------------------------------ListViewのxml------------------------------------------------------//
152
154
 
153
- <ScrollView
155
+
154
-
155
- android:id="@+id/scrollview"
156
-
157
- android:layout_width="match_parent"
158
-
159
- android:layout_height="0dp"
160
-
161
- android:layout_margin="20dp"
162
-
163
- android:layout_weight="1">
164
156
 
165
157
 
166
158
 
@@ -180,8 +172,4 @@
180
172
 
181
173
 
182
174
 
183
- </ScrollView>
184
-
185
-
186
-
187
175
  ```

5

ListViewがScrollViewに囲まれていたのでそう書きました。

2017/05/09 03:07

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -150,7 +150,21 @@
150
150
 
151
151
  //----------------------------------------------------ListViewのxml------------------------------------------------------//
152
152
 
153
+ <ScrollView
154
+
155
+ android:id="@+id/scrollview"
156
+
157
+ android:layout_width="match_parent"
158
+
159
+ android:layout_height="0dp"
160
+
161
+ android:layout_margin="20dp"
162
+
163
+ android:layout_weight="1">
164
+
165
+
166
+
153
- <ListView
167
+ <ListView
154
168
 
155
169
  android:id="@+id/list_view"
156
170
 
@@ -158,6 +172,16 @@
158
172
 
159
173
  android:layout_height="wrap_content"
160
174
 
161
- android:textColor="#000" ></ListView>
175
+ android:textColor="#000"
176
+
177
+ ></ListView>
178
+
179
+
180
+
181
+
182
+
183
+ </ScrollView>
184
+
185
+
162
186
 
163
187
  ```

4

Log出力の表示

2017/05/09 02:56

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -134,6 +134,12 @@
134
134
 
135
135
  select();
136
136
 
137
+
138
+
139
+ System.out.println("select後のlistItemのlength:"+listItems.length);
140
+
141
+ //このように表示されます。 I/System.out: select後のlistItemのlength:57
142
+
137
143
 
138
144
 
139
145
  }

3

ListViewを増やすとは

2017/05/09 02:03

投稿

edoooooo
edoooooo

スコア476

test CHANGED
@@ -1 +1 @@
1
- 動的なListViewを作成して、listItems[]が大きくなるたびに、ListViewも増やしたい。
1
+ 動的なListViewを作成して、listItems[]が大きくなるたびに、ListViewのlistの数も増やしたい。
test CHANGED
File without changes

2

コードの変更

2017/05/09 01:46

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -96,6 +96,16 @@
96
96
 
97
97
  }
98
98
 
99
+ ListView listView = (ListView) findViewById(R.id.list_view);
100
+
101
+
102
+
103
+ ArrayAdapter<String> adapterlist = new ArrayAdapter<String>(LocationActivity.this, android.R.layout.simple_list_item_1, listItems);
104
+
105
+ adapterlist.setDropDownViewResource(android.R.layout.simple_list_item_1);
106
+
107
+ listView.setAdapter(adapterlist);
108
+
99
109
  }
100
110
 
101
111
  }
@@ -116,15 +126,15 @@
116
126
 
117
127
 
118
128
 
119
- ListView listView = (ListView) findViewById(R.id.list_view);
129
+ listItems = new String[1];
130
+
131
+ listItems[0] = "";
120
132
 
121
133
 
122
134
 
123
- ArrayAdapter<String> adapterlist = new ArrayAdapter<String>(LocationActivity.this, android.R.layout.simple_list_item_1, listItems);
135
+ select();
124
136
 
125
- adapterlist.setDropDownViewResource(android.R.layout.simple_list_item_1);
137
+
126
-
127
- listView.setAdapter(adapterlist);
128
138
 
129
139
  }
130
140
 

1

説明のついか 

2017/05/09 01:45

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -19,6 +19,12 @@
19
19
  この
20
20
 
21
21
  動的なListViewを作成して、listItems[]が大きくなるたびに、ListViewも増やすためには、どうすればいいのでしょうか?
22
+
23
+
24
+
25
+ http://qiita.com/joji/items/dca48fb0e915077a01b2
26
+
27
+ 後から、このサイトと同じことに気づいたのですが、なぜか表示されません。
22
28
 
23
29
 
24
30