Reputation: 4013
With android studio I'm trying to create a custom ListView
. The app doesn't crash but there aren't the items
that I'm trying to show on my ListView
. When I run it here is a list
but nothing in there in the rows; also I can scroll it and I can click on the rows with no problem.
Here's my ListView
in MainActivity
:
CustomList adapter = new CustomList(this,myRssFeed.getList());
adapter.addAll();
setListAdapter(adapter);
my CustomAdapter
:
public class CustomList extends ArrayAdapter<RSSItem> {
private final Activity context;
private final List<RSSItem> web;
public CustomList(Activity context, List<RSSItem> web) {
super(context, R.layout.list_item, web);
this.context = context;
this.web = web;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.list_item, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
txtTitle.setText((CharSequence) getTitle());
return rowView;
}
private RSSItem getTitle() {
return null;
}
Upvotes: 0
Views: 138
Reputation: 3204
change this:
private RSSItem getTitle() {
return null;
}
To:
private RSSItem getTitle(int position) {
return web.get(position);
}
And change this:
txtTitle.setText((CharSequence) getTitle());
To:
txtTitle.setText((CharSequence) getTitle(position));
Upvotes: 0
Reputation: 134
Try updating as below
TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
txtTitle.setText(web.get(pos).getTitle());
Upvotes: 1