使用android studio我正在尝试创建自定义ListView
。该应用不会崩溃但我没有尝试在items
上展示ListView
。当我在这里运行它是list
但行中没有任何东西;我也可以滚动它,我可以毫无问题地点击行。
这是ListView
中的MainActivity
:
CustomList adapter = new CustomList(this,myRssFeed.getList());
adapter.addAll();
setListAdapter(adapter);
我的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;
}
答案 0 :(得分:1)
尝试更新如下
TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
txtTitle.setText(web.get(pos).getTitle());
答案 1 :(得分:0)
改变这个:
private RSSItem getTitle() {
return null;
}
要:
private RSSItem getTitle(int position) {
return web.get(position);
}
并改变这一点:
txtTitle.setText((CharSequence) getTitle());
要:
txtTitle.setText((CharSequence) getTitle(position));