So I found some code that I am trying to get working. I am new to Android/Exclipse/Java and still trying to wrap my head around the whole thing. However, I am starring myself blind.
Say I have this:
private class RSSListAdapter extends ArrayAdapter<MyRSSItem> {
private List<MyRSSItem> objects = null;
public RSSListAdapter(Context context, int viewid, List<MyRSSItem> objects) {
super(context, viewid, objects);
this.objects = objects;
}
}
and then elsewhere this:
myRssAdapter = new RSSListAdapter(thisActivityContext, newsListView, myItemsDataArrayList);
where myItemsDataArrayList is declared like this:
ArrayList<MyRSSItem> myItemsDataArrayList = new ArrayList<MyRSSItem>();
I get this error:
The constructor News.RSSListAdaptor(Context, ListView, ArrayList) is undefined
Of course I have tried Google, but, well, no luck.
The constructor’s definition is this:
This means it accepts in only a
Context, anint, and aList <MyRSSItem>However, you call the constructor with these arguments:
the second argument is a
newsListView, which isn’t anint, it is aListView. They are not the same type, hence the compile-time error.If you change to
android.R.id.text1, it should work, since that is a valid TextView id, like the superclass constructor requires.And definitely don’t forget to set the
ListView‘s adapter to yourRSSListAdapterafter creating it.For more detailed info, this tutorial is pretty helpful.