1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.listrow, null);
}
ListeArret o = getItem(position);
if (o != null) {
TextView tt = (TextView) v.findViewById(R.id.station);
if (tt != null) {
tt.setText(o.getLibelle());
}
TextView bb = (TextView) v.findViewById(R.id.distance);
if (bb != null) {
Log.v("", "getDistance:" + o.getDistance());
bb.setText(o.getDistance());
}
// ImageView image=(ImageView)v.findViewById(R.id.numeroligne);
TableLayout table = (TableLayout)v.findViewById(R.id.TableLayout01);
LinearLayout layout = (LinearLayout) v
.findViewById(R.id.monlayout);
int count=0;
for (int i = 0; i < o.getLignes().size(); i++) {
TableRow row = new TableRow(getContext());
if(count==3){
row = new TableRow(getContext());
count=0;
}
ImageView image = new ImageView(getContext());
int resid = getContext().getResources().getIdentifier(
"ligne_"
+ o.getLignes().get(i).getNumLigne()
.toLowerCase(), "drawable",
"com.test.base");
image.setImageResource(resid);
row.addView(image, new TableRow.LayoutParams(25, 25));
table.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
count++;
}
layout.addView(table,new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} |
Partager