Mac Systems
- Forum-Beiträge: 1.727
09.07.2009, 11:38:34 via Website
09.07.2009 11:38:34 via Website
1public class SpotOverviewAdapter extends BaseAdapter
2{ private final Context context; private final List<SpotConfigurationVO> spotList; private final int rowResID;
3 /** * * @param _context * @param _rowResID * @param _spotList */ public SpotOverviewAdapter(final Context _context, final int _rowResID, final List<SpotConfigurationVO> _spotList) { context = _context; rowResID = _rowResID; spotList = _spotList; }
4 public int getCount() { return spotList.size(); }
5 public Object getItem(int position) { return spotList.get(position); }
6 public long getItemId(int position) { return position; }
7 public View getView(int position, View convertView, ViewGroup parent) { final SpotConfigurationVO weather = spotList.get(position);
8 final View view = View.inflate(context, rowResID, parent); view.setBackgroundColor(Color.BLUE); // ViewInflate inflate = ViewInflate.from(context); // View v = inflate.inflate(rowResID, parent, false, null); // TextView cityControl = (TextView) v.findViewById(R.id.city);
9 return view; }
10}
2{ private final Context context; private final List<SpotConfigurationVO> spotList; private final int rowResID;
3 /** * * @param _context * @param _rowResID * @param _spotList */ public SpotOverviewAdapter(final Context _context, final int _rowResID, final List<SpotConfigurationVO> _spotList) { context = _context; rowResID = _rowResID; spotList = _spotList; }
4 public int getCount() { return spotList.size(); }
5 public Object getItem(int position) { return spotList.get(position); }
6 public long getItemId(int position) { return position; }
7 public View getView(int position, View convertView, ViewGroup parent) { final SpotConfigurationVO weather = spotList.get(position);
8 final View view = View.inflate(context, rowResID, parent); view.setBackgroundColor(Color.BLUE); // ViewInflate inflate = ViewInflate.from(context); // View v = inflate.inflate(rowResID, parent, false, null); // TextView cityControl = (TextView) v.findViewById(R.id.city);
9 return view; }
10}
Folgender Code schmeißt mir grundsätzlich folgende Exception: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
Da ich meine verstanden zu haben wie Adapter zu benutzten sind sollte folgendes Layout funktionieren:
1<?xml version="1.0" encoding="UTF-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
3 <TextView android:id="@+id/custom_spotoverview_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="20sp" />
4 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent">
5 <TextView android:id="@+id/custom_spotoverview_tralala" android:text="@string/no_entrys" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/custom_spotoverview_tralala3" android:background="@drawable/wd_wsw" android:layout_width="wrap_content" android:layout_height="wrap_content" />
6 <ImageView android:id="@+id/custom_spotoverview_tralala4" android:background="@drawable/wd_n" android:layout_width="wrap_content" android:layout_height="wrap_content" />
7 </LinearLayout>
8</LinearLayout>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
3 <TextView android:id="@+id/custom_spotoverview_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="20sp" />
4 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent">
5 <TextView android:id="@+id/custom_spotoverview_tralala" android:text="@string/no_entrys" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/custom_spotoverview_tralala3" android:background="@drawable/wd_wsw" android:layout_width="wrap_content" android:layout_height="wrap_content" />
6 <ImageView android:id="@+id/custom_spotoverview_tralala4" android:background="@drawable/wd_n" android:layout_width="wrap_content" android:layout_height="wrap_content" />
7 </LinearLayout>
8</LinearLayout>
Mir geht es darum halt die Objecte vom Typ SpotConfigurationVO nutzen zu können um später entsprechend z.b ein ImageView mit einem Drawable zu versorgen.
Hat jemand eine Lösung dafür ?
PS: Die Codeformatierung wird mal wieder nach dem "Speichern" total verhunzt! Das Forum wird dadurch unbrauchbar!
— geändert am 09.07.2009, 11:43:13
Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.