我正在尝试使用基本适配器来使用我的对象(NewsFeedObj)中的字段填充我的列表视图我目前只是想获取描述字段。当我运行我的代码时,我只是得到一个空白活动?谁能帮我
public class News_Feed_BaseAdapter extends BaseAdapter {
private Context context;
private List<NewsFeedObj> obj = Collections.emptyList();
public News_Feed_BaseAdapter(Context context, List<NewsFeedObj> obj) {
this.context = context;
this.obj = obj;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return obj.size();
}
@Override
public NewsFeedObj getItem(int position) {
// TODO Auto-generated method stub
return obj.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.newfeed_layout, parent, false);
}
TextView t = (TextView) convertView.findViewById(R.id.Description);
NewsFeedObj o = getItem(position);
t.setText(o.get_description());
return convertView;
}
}
在主要活动中
ArrayList<NewsFeedObj> NewsObjs = new ArrayList<NewsFeedObj>();
NewsObjs = j.new_feed_Array_List(); // returns an array list of
// NewsFeedObj
ListView l = getListView();
News_Feed_BaseAdapter A = new News_Feed_BaseAdapter(this, NewsObjs);
l.setAdapter(A);