質問編集履歴
2
不要な箇所の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
お知恵をお貸し下さい。
|
6
6
|
|
7
7
|
```lang-<ここに言語を入力>
|
8
|
-
public class
|
8
|
+
public class Top extends ActionBarActivity {
|
9
9
|
private ListView listview;
|
10
10
|
private ArrayList<TopElement> TopItems;
|
11
11
|
|
@@ -26,11 +26,8 @@
|
|
26
26
|
for (int i = 0; i < maxLength; i++) {
|
27
27
|
TopElement item = new TopElement();
|
28
28
|
item.setAccountIcon(R.drawable.ic_launcher);
|
29
|
-
item.setAccountName("User Name");
|
30
|
-
item.setTimeLineImage(R.drawable.ic_launcher);
|
31
29
|
item.setTopImage(R.drawable.ic_launcher);
|
32
30
|
item.setTopImage(R.drawable.ic_launcher);
|
33
|
-
item.setTimeLineText("TestTestTestTestTestTestTestTestTestTest");
|
34
31
|
|
35
32
|
TopItems.add(item);
|
36
33
|
}
|
@@ -41,112 +38,4 @@
|
|
41
38
|
|
42
39
|
}
|
43
40
|
}
|
44
|
-
```
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
```lang-<ここに言語を入力>
|
49
|
-
class TopListViewAdpater extends ArrayAdapter<TopElement> {
|
50
|
-
public TopListViewAdpater(Context context, ArrayList<TopElement> TopItems) {
|
51
|
-
super(context, R.layout._top_listview, TopItems);
|
52
|
-
}
|
53
|
-
|
54
|
-
@Override
|
55
|
-
public View getView(int position, View convertView, ViewGroup parent) {
|
56
|
-
ViewHolder viewHolder;
|
57
|
-
|
58
|
-
if(convertView == null) {
|
59
|
-
LayoutInflater inflater = LayoutInflater.from(getContext());
|
60
|
-
convertView = inflater.inflate(R.layout._top_listview, parent, false);
|
61
|
-
|
62
|
-
viewHolder = new ViewHolder();
|
63
|
-
viewHolder.accountName = (TextView) convertView.findViewById(R.id.accountName);
|
64
|
-
viewHolder.timeLineText = (TextView) convertView.findViewById(R.id.timeLineText);
|
65
|
-
viewHolder.accountIcon = (ImageView) convertView.findViewById(R.id.accountIcon);
|
66
|
-
viewHolder.timeLineImage = (ImageView) convertView.findViewById(R.id.timeLineImage);
|
67
|
-
|
68
|
-
convertView.setTag(viewHolder);
|
69
|
-
|
70
|
-
} else {
|
71
|
-
viewHolder = (ViewHolder) convertView.getTag();
|
72
|
-
}
|
73
|
-
|
74
|
-
TopElement item = getItem(position);
|
75
|
-
viewHolder.accountName.setText(item.getAccountName());
|
76
|
-
viewHolder.timeLineText.setText(item.getTimeLineText());
|
77
|
-
viewHolder.accountIcon.setImageResource(item.getAccountIcon());
|
78
|
-
viewHolder.timeLineImage.setImageResource(item.getTimeLineImage());
|
79
|
-
|
80
|
-
return convertView;
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
private class ViewHolder {
|
85
|
-
ImageView accountIcon, timeLineImage ;
|
86
|
-
TextView accountName, timeLineText;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
```
|
90
|
-
|
91
|
-
|
92
|
-
```lang-<ここに言語を入力>
|
93
|
-
public class TopElement {
|
94
|
-
|
95
|
-
timeLineText
|
96
|
-
String TopTitle;
|
97
|
-
int TopImage;
|
98
|
-
int accountIcon;
|
99
|
-
String accountName;
|
100
|
-
int timeLineImage;
|
101
|
-
String timeLineText;
|
102
|
-
|
103
|
-
public String getTopTitle() {
|
104
|
-
return TopTitle;
|
105
|
-
}
|
106
|
-
|
107
|
-
public void setTopTitle(String TopTitle) {
|
108
|
-
this.TopTitle = TopTitle;
|
109
|
-
}
|
110
|
-
|
111
|
-
public int getTopImage() {
|
112
|
-
return TopImage;
|
113
|
-
}
|
114
|
-
|
115
|
-
public void setTopImage(int TopImage) {
|
116
|
-
this.TopImage = TopImage;
|
117
|
-
}
|
118
|
-
|
119
|
-
public int getAccountIcon() {
|
120
|
-
return accountIcon;
|
121
|
-
}
|
122
|
-
|
123
|
-
public void setAccountIcon(int accountIcon) {
|
124
|
-
this.accountIcon = accountIcon;
|
125
|
-
}
|
126
|
-
|
127
|
-
public String getAccountName() {
|
128
|
-
return accountName;
|
129
|
-
}
|
130
|
-
|
131
|
-
public void setAccountName(String accountName) {
|
132
|
-
this.accountName = accountName;
|
133
|
-
}
|
134
|
-
|
135
|
-
public int getTimeLineImage() {
|
136
|
-
return timeLineImage;
|
137
|
-
}
|
138
|
-
|
139
|
-
public void setTimeLineImage(int timeLineImage) {
|
140
|
-
this.timeLineImage = timeLineImage;
|
141
|
-
}
|
142
|
-
|
143
|
-
public String getTimeLineText() {
|
144
|
-
return timeLineText;
|
145
|
-
}
|
146
|
-
|
147
|
-
public void setTimeLineText(String timeLineText) {
|
148
|
-
this.timeLineText = timeLineText;
|
149
|
-
}
|
150
|
-
|
151
|
-
}
|
152
41
|
```
|
1
無駄なコードを修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,16 +14,12 @@
|
|
14
14
|
super.onCreate(savedInstanceState);
|
15
15
|
setContentView(R.layout.new__top);
|
16
16
|
|
17
|
-
|
18
|
-
//戻るボタン
|
19
17
|
getSupportActionBar().setHomeButtonEnabled(true);
|
20
18
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
21
19
|
|
22
20
|
|
23
|
-
//TopListViewはここから
|
24
21
|
// TODO: Delete dummy data
|
25
22
|
TopItems = new ArrayList<TopElement>();
|
26
|
-
//ArrayList<型> 変数名
|
27
23
|
|
28
24
|
int maxLength = 3;
|
29
25
|
|
@@ -34,7 +30,7 @@
|
|
34
30
|
item.setTimeLineImage(R.drawable.ic_launcher);
|
35
31
|
item.setTopImage(R.drawable.ic_launcher);
|
36
32
|
item.setTopImage(R.drawable.ic_launcher);
|
37
|
-
item.setTimeLineText("
|
33
|
+
item.setTimeLineText("TestTestTestTestTestTestTestTestTestTest");
|
38
34
|
|
39
35
|
TopItems.add(item);
|
40
36
|
}
|
@@ -44,33 +40,6 @@
|
|
44
40
|
listView.setAdapter(arrayAdapter);
|
45
41
|
|
46
42
|
}
|
47
|
-
|
48
|
-
|
49
|
-
@Override
|
50
|
-
public boolean onOptionsItemSelected(MenuItem item) {
|
51
|
-
switch (item.getItemId()) {
|
52
|
-
|
53
|
-
//遷移先がフラグメントなので、FragmentTransactionで書く。
|
54
|
-
case R.id.menu_home:
|
55
|
-
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
56
|
-
ft.replace(R.id.container, new All());
|
57
|
-
break;
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
finish();
|
63
|
-
return super.onOptionsItemSelected(item);
|
64
|
-
}
|
65
|
-
|
66
|
-
@Override
|
67
|
-
public boolean onCreateOptionsMenu(Menu menu) {
|
68
|
-
// Inflate the menu; this adds items to the action bar if it is present.
|
69
|
-
getMenuInflater().inflate(R.menu.menu, menu);
|
70
|
-
return true;
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
43
|
}
|
75
44
|
```
|
76
45
|
|
@@ -123,9 +92,9 @@
|
|
123
92
|
```lang-<ここに言語を入力>
|
124
93
|
public class TopElement {
|
125
94
|
|
126
|
-
|
95
|
+
timeLineText
|
127
|
-
String TopTitle;
|
96
|
+
String TopTitle;
|
128
|
-
int TopImage;
|
97
|
+
int TopImage;
|
129
98
|
int accountIcon;
|
130
99
|
String accountName;
|
131
100
|
int timeLineImage;
|