I am writing a custom adapter to populate a list with 3 text fields per line. For this, I found a pretty sample code, but the one that seemed the best was: http://www.anddev.org/custom_widget_adapters-t1796.html
After a few small tweaks to fix some problems with the compiler with the latest Android SDK, I got it just to get an exception:
ERROR / AndroidRuntime (281): java.lang.UnsupportedOperationException: addView (View, LayoutParams) is not supported in AdapterView
So, I did a lot of research and found many possible causes and corrections for this. None of this has changed. My adapter code now:
public class WeatherAdapter extends BaseAdapter { private Context context; private List<Weather> weatherList; public WeatherAdapter(Context context, int rowResID, List<Weather> weatherList ) { this.context = context; this.weatherList = weatherList; } public int getCount() { return weatherList.size(); } public Object getItem(int position) { return weatherList.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { Weather weather = weatherList.get(position);
So, I tried to comment on the way to get a scammer, and currently it is not framed. I tried passing “parent” to inflate as well as “zero”, and passed “true”, “false” and completely excluded the last parameter. None of them worked, and all the examples that I have found so far have been since 2008, which I feel is a bit outdated.
If anyone can help with this, I would happily solve the problem.
android android-layout listview android-xml android-adapter
Teknogrebo Nov 29 '10 at 17:29 2010-11-29 17:29
source share