質問編集履歴

2

不要な箇所の変更

2015/03/16 13:42

投稿

kaaa
kaaa

スコア29

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ```lang-<ここに言語を入力>
14
14
 
15
- public class NewTop extends ActionBarActivity {
15
+ public class Top extends ActionBarActivity {
16
16
 
17
17
  private ListView listview;
18
18
 
@@ -54,15 +54,9 @@
54
54
 
55
55
  item.setAccountIcon(R.drawable.ic_launcher);
56
56
 
57
- item.setAccountName("User Name");
58
-
59
- item.setTimeLineImage(R.drawable.ic_launcher);
60
-
61
57
  item.setTopImage(R.drawable.ic_launcher);
62
58
 
63
59
  item.setTopImage(R.drawable.ic_launcher);
64
-
65
- item.setTimeLineText("TestTestTestTestTestTestTestTestTestTest");
66
60
 
67
61
 
68
62
 
@@ -85,219 +79,3 @@
85
79
  }
86
80
 
87
81
  ```
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- ```lang-<ここに言語を入力>
96
-
97
- class TopListViewAdpater extends ArrayAdapter<TopElement> {
98
-
99
- public TopListViewAdpater(Context context, ArrayList<TopElement> TopItems) {
100
-
101
- super(context, R.layout._top_listview, TopItems);
102
-
103
- }
104
-
105
-
106
-
107
- @Override
108
-
109
- public View getView(int position, View convertView, ViewGroup parent) {
110
-
111
- ViewHolder viewHolder;
112
-
113
-
114
-
115
- if(convertView == null) {
116
-
117
- LayoutInflater inflater = LayoutInflater.from(getContext());
118
-
119
- convertView = inflater.inflate(R.layout._top_listview, parent, false);
120
-
121
-
122
-
123
- viewHolder = new ViewHolder();
124
-
125
- viewHolder.accountName = (TextView) convertView.findViewById(R.id.accountName);
126
-
127
- viewHolder.timeLineText = (TextView) convertView.findViewById(R.id.timeLineText);
128
-
129
- viewHolder.accountIcon = (ImageView) convertView.findViewById(R.id.accountIcon);
130
-
131
- viewHolder.timeLineImage = (ImageView) convertView.findViewById(R.id.timeLineImage);
132
-
133
-
134
-
135
- convertView.setTag(viewHolder);
136
-
137
-
138
-
139
- } else {
140
-
141
- viewHolder = (ViewHolder) convertView.getTag();
142
-
143
- }
144
-
145
-
146
-
147
- TopElement item = getItem(position);
148
-
149
- viewHolder.accountName.setText(item.getAccountName());
150
-
151
- viewHolder.timeLineText.setText(item.getTimeLineText());
152
-
153
- viewHolder.accountIcon.setImageResource(item.getAccountIcon());
154
-
155
- viewHolder.timeLineImage.setImageResource(item.getTimeLineImage());
156
-
157
-
158
-
159
- return convertView;
160
-
161
- }
162
-
163
-
164
-
165
-
166
-
167
- private class ViewHolder {
168
-
169
- ImageView accountIcon, timeLineImage ;
170
-
171
- TextView accountName, timeLineText;
172
-
173
- }
174
-
175
- }
176
-
177
- ```
178
-
179
-
180
-
181
-
182
-
183
- ```lang-<ここに言語を入力>
184
-
185
- public class TopElement {
186
-
187
-
188
-
189
- timeLineText
190
-
191
- String TopTitle;
192
-
193
- int TopImage;
194
-
195
- int accountIcon;
196
-
197
- String accountName;
198
-
199
- int timeLineImage;
200
-
201
- String timeLineText;
202
-
203
-
204
-
205
- public String getTopTitle() {
206
-
207
- return TopTitle;
208
-
209
- }
210
-
211
-
212
-
213
- public void setTopTitle(String TopTitle) {
214
-
215
- this.TopTitle = TopTitle;
216
-
217
- }
218
-
219
-
220
-
221
- public int getTopImage() {
222
-
223
- return TopImage;
224
-
225
- }
226
-
227
-
228
-
229
- public void setTopImage(int TopImage) {
230
-
231
- this.TopImage = TopImage;
232
-
233
- }
234
-
235
-
236
-
237
- public int getAccountIcon() {
238
-
239
- return accountIcon;
240
-
241
- }
242
-
243
-
244
-
245
- public void setAccountIcon(int accountIcon) {
246
-
247
- this.accountIcon = accountIcon;
248
-
249
- }
250
-
251
-
252
-
253
- public String getAccountName() {
254
-
255
- return accountName;
256
-
257
- }
258
-
259
-
260
-
261
- public void setAccountName(String accountName) {
262
-
263
- this.accountName = accountName;
264
-
265
- }
266
-
267
-
268
-
269
- public int getTimeLineImage() {
270
-
271
- return timeLineImage;
272
-
273
- }
274
-
275
-
276
-
277
- public void setTimeLineImage(int timeLineImage) {
278
-
279
- this.timeLineImage = timeLineImage;
280
-
281
- }
282
-
283
-
284
-
285
- public String getTimeLineText() {
286
-
287
- return timeLineText;
288
-
289
- }
290
-
291
-
292
-
293
- public void setTimeLineText(String timeLineText) {
294
-
295
- this.timeLineText = timeLineText;
296
-
297
- }
298
-
299
-
300
-
301
- }
302
-
303
- ```

1

無駄なコードを修正しました。

2015/03/16 13:42

投稿

kaaa
kaaa

スコア29

test CHANGED
File without changes
test CHANGED
@@ -30,10 +30,6 @@
30
30
 
31
31
 
32
32
 
33
-
34
-
35
- //戻るボタン
36
-
37
33
  getSupportActionBar().setHomeButtonEnabled(true);
38
34
 
39
35
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@@ -42,14 +38,10 @@
42
38
 
43
39
 
44
40
 
45
- //TopListViewはここから
46
-
47
41
  // TODO: Delete dummy data
48
42
 
49
43
  TopItems = new ArrayList<TopElement>();
50
44
 
51
- //ArrayList<型> 変数名
52
-
53
45
 
54
46
 
55
47
  int maxLength = 3;
@@ -70,7 +62,7 @@
70
62
 
71
63
  item.setTopImage(R.drawable.ic_launcher);
72
64
 
73
- item.setTimeLineText("TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest");
65
+ item.setTimeLineText("TestTestTestTestTestTestTestTestTestTest");
74
66
 
75
67
 
76
68
 
@@ -90,59 +82,95 @@
90
82
 
91
83
  }
92
84
 
93
-
85
+ }
86
+
87
+ ```
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ ```lang-<ここに言語を入力>
96
+
97
+ class TopListViewAdpater extends ArrayAdapter<TopElement> {
98
+
99
+ public TopListViewAdpater(Context context, ArrayList<TopElement> TopItems) {
100
+
101
+ super(context, R.layout._top_listview, TopItems);
102
+
103
+ }
94
104
 
95
105
 
96
106
 
97
107
  @Override
98
108
 
99
- public boolean onOptionsItemSelected(MenuItem item) {
109
+ public View getView(int position, View convertView, ViewGroup parent) {
110
+
100
-
111
+ ViewHolder viewHolder;
112
+
113
+
114
+
101
- switch (item.getItemId()) {
115
+ if(convertView == null) {
102
-
103
-
104
-
105
- //遷移先がフラグメントなので、FragmentTransactionで書く。
116
+
106
-
107
- case R.id.menu_home:
108
-
109
- FragmentTransaction ft = getFragmentManager().beginTransaction();
117
+ LayoutInflater inflater = LayoutInflater.from(getContext());
118
+
110
-
119
+ convertView = inflater.inflate(R.layout._top_listview, parent, false);
120
+
121
+
122
+
123
+ viewHolder = new ViewHolder();
124
+
125
+ viewHolder.accountName = (TextView) convertView.findViewById(R.id.accountName);
126
+
127
+ viewHolder.timeLineText = (TextView) convertView.findViewById(R.id.timeLineText);
128
+
129
+ viewHolder.accountIcon = (ImageView) convertView.findViewById(R.id.accountIcon);
130
+
131
+ viewHolder.timeLineImage = (ImageView) convertView.findViewById(R.id.timeLineImage);
132
+
133
+
134
+
111
- ft.replace(R.id.container, new All());
135
+ convertView.setTag(viewHolder);
112
-
136
+
137
+
138
+
113
- break;
139
+ } else {
140
+
114
-
141
+ viewHolder = (ViewHolder) convertView.getTag();
115
-
116
-
117
-
118
142
 
119
143
  }
120
144
 
121
145
 
122
146
 
123
- finish();
124
-
125
- return super.onOptionsItemSelected(item);
147
+ TopElement item = getItem(position);
148
+
126
-
149
+ viewHolder.accountName.setText(item.getAccountName());
150
+
151
+ viewHolder.timeLineText.setText(item.getTimeLineText());
152
+
153
+ viewHolder.accountIcon.setImageResource(item.getAccountIcon());
154
+
155
+ viewHolder.timeLineImage.setImageResource(item.getTimeLineImage());
156
+
157
+
158
+
159
+ return convertView;
160
+
127
- }
161
+ }
128
-
129
-
130
-
162
+
163
+
164
+
165
+
166
+
131
- @Override
167
+ private class ViewHolder {
132
-
168
+
133
- public boolean onCreateOptionsMenu(Menu menu) {
169
+ ImageView accountIcon, timeLineImage ;
134
-
135
- // Inflate the menu; this adds items to the action bar if it is present.
170
+
136
-
137
- getMenuInflater().inflate(R.menu.menu, menu);
171
+ TextView accountName, timeLineText;
138
-
139
- return true;
172
+
140
-
141
- }
173
+ }
142
-
143
-
144
-
145
-
146
174
 
147
175
  }
148
176
 
@@ -152,214 +180,124 @@
152
180
 
153
181
 
154
182
 
155
-
156
-
157
183
  ```lang-<ここに言語を入力>
158
184
 
159
- class TopListViewAdpater extends ArrayAdapter<TopElement> {
160
-
161
- public TopListViewAdpater(Context context, ArrayList<TopElement> TopItems) {
162
-
163
- super(context, R.layout._top_listview, TopItems);
164
-
165
- }
166
-
167
-
168
-
169
- @Override
170
-
171
- public View getView(int position, View convertView, ViewGroup parent) {
172
-
173
- ViewHolder viewHolder;
174
-
175
-
176
-
177
- if(convertView == null) {
178
-
179
- LayoutInflater inflater = LayoutInflater.from(getContext());
180
-
181
- convertView = inflater.inflate(R.layout._top_listview, parent, false);
182
-
183
-
184
-
185
- viewHolder = new ViewHolder();
186
-
187
- viewHolder.accountName = (TextView) convertView.findViewById(R.id.accountName);
188
-
189
- viewHolder.timeLineText = (TextView) convertView.findViewById(R.id.timeLineText);
190
-
191
- viewHolder.accountIcon = (ImageView) convertView.findViewById(R.id.accountIcon);
192
-
193
- viewHolder.timeLineImage = (ImageView) convertView.findViewById(R.id.timeLineImage);
194
-
195
-
196
-
197
- convertView.setTag(viewHolder);
198
-
199
-
200
-
201
- } else {
202
-
203
- viewHolder = (ViewHolder) convertView.getTag();
204
-
205
- }
206
-
207
-
208
-
209
- TopElement item = getItem(position);
210
-
211
- viewHolder.accountName.setText(item.getAccountName());
212
-
213
- viewHolder.timeLineText.setText(item.getTimeLineText());
214
-
215
- viewHolder.accountIcon.setImageResource(item.getAccountIcon());
216
-
217
- viewHolder.timeLineImage.setImageResource(item.getTimeLineImage());
218
-
219
-
220
-
221
- return convertView;
222
-
223
- }
224
-
225
-
226
-
227
-
228
-
229
- private class ViewHolder {
230
-
231
- ImageView accountIcon, timeLineImage ;
232
-
233
- TextView accountName, timeLineText;
234
-
235
- }
185
+ public class TopElement {
186
+
187
+
188
+
189
+ timeLineText
190
+
191
+ String TopTitle;
192
+
193
+ int TopImage;
194
+
195
+ int accountIcon;
196
+
197
+ String accountName;
198
+
199
+ int timeLineImage;
200
+
201
+ String timeLineText;
202
+
203
+
204
+
205
+ public String getTopTitle() {
206
+
207
+ return TopTitle;
208
+
209
+ }
210
+
211
+
212
+
213
+ public void setTopTitle(String TopTitle) {
214
+
215
+ this.TopTitle = TopTitle;
216
+
217
+ }
218
+
219
+
220
+
221
+ public int getTopImage() {
222
+
223
+ return TopImage;
224
+
225
+ }
226
+
227
+
228
+
229
+ public void setTopImage(int TopImage) {
230
+
231
+ this.TopImage = TopImage;
232
+
233
+ }
234
+
235
+
236
+
237
+ public int getAccountIcon() {
238
+
239
+ return accountIcon;
240
+
241
+ }
242
+
243
+
244
+
245
+ public void setAccountIcon(int accountIcon) {
246
+
247
+ this.accountIcon = accountIcon;
248
+
249
+ }
250
+
251
+
252
+
253
+ public String getAccountName() {
254
+
255
+ return accountName;
256
+
257
+ }
258
+
259
+
260
+
261
+ public void setAccountName(String accountName) {
262
+
263
+ this.accountName = accountName;
264
+
265
+ }
266
+
267
+
268
+
269
+ public int getTimeLineImage() {
270
+
271
+ return timeLineImage;
272
+
273
+ }
274
+
275
+
276
+
277
+ public void setTimeLineImage(int timeLineImage) {
278
+
279
+ this.timeLineImage = timeLineImage;
280
+
281
+ }
282
+
283
+
284
+
285
+ public String getTimeLineText() {
286
+
287
+ return timeLineText;
288
+
289
+ }
290
+
291
+
292
+
293
+ public void setTimeLineText(String timeLineText) {
294
+
295
+ this.timeLineText = timeLineText;
296
+
297
+ }
298
+
299
+
236
300
 
237
301
  }
238
302
 
239
303
  ```
240
-
241
-
242
-
243
-
244
-
245
- ```lang-<ここに言語を入力>
246
-
247
- public class TopElement {
248
-
249
-
250
-
251
- //必要になる要素title, topImage, accontIcon, accountName, timeLineImage, timeLineText
252
-
253
- String TopTitle; //と被るので要らないかも
254
-
255
- int TopImage; //と被るので要らないかも
256
-
257
- int accountIcon;
258
-
259
- String accountName;
260
-
261
- int timeLineImage;
262
-
263
- String timeLineText;
264
-
265
-
266
-
267
- public String getTopTitle() {
268
-
269
- return TopTitle;
270
-
271
- }
272
-
273
-
274
-
275
- public void setTopTitle(String TopTitle) {
276
-
277
- this.TopTitle = TopTitle;
278
-
279
- }
280
-
281
-
282
-
283
- public int getTopImage() {
284
-
285
- return TopImage;
286
-
287
- }
288
-
289
-
290
-
291
- public void setTopImage(int TopImage) {
292
-
293
- this.TopImage = TopImage;
294
-
295
- }
296
-
297
-
298
-
299
- public int getAccountIcon() {
300
-
301
- return accountIcon;
302
-
303
- }
304
-
305
-
306
-
307
- public void setAccountIcon(int accountIcon) {
308
-
309
- this.accountIcon = accountIcon;
310
-
311
- }
312
-
313
-
314
-
315
- public String getAccountName() {
316
-
317
- return accountName;
318
-
319
- }
320
-
321
-
322
-
323
- public void setAccountName(String accountName) {
324
-
325
- this.accountName = accountName;
326
-
327
- }
328
-
329
-
330
-
331
- public int getTimeLineImage() {
332
-
333
- return timeLineImage;
334
-
335
- }
336
-
337
-
338
-
339
- public void setTimeLineImage(int timeLineImage) {
340
-
341
- this.timeLineImage = timeLineImage;
342
-
343
- }
344
-
345
-
346
-
347
- public String getTimeLineText() {
348
-
349
- return timeLineText;
350
-
351
- }
352
-
353
-
354
-
355
- public void setTimeLineText(String timeLineText) {
356
-
357
- this.timeLineText = timeLineText;
358
-
359
- }
360
-
361
-
362
-
363
- }
364
-
365
- ```