我想在使用扩展ListView
的自定义适配器的Fragment
中添加BaseAdapter
。
我不想通过ListFragment
尝试它,因为我已经在那个片段中篡改了很多代码。
你能帮我在ListView
中添加Fragment
。
adapter = new MyTableAdapter(getActivity(), list);
list.setAdapter(adapter);
和适配器类
public class MyTableAdapter extends BaseAdapter {
List<Root.StandingBean> list;
Activity context;
public MyTableAdapter(Activity context, List<Root.StandingBean> list) {
this.context = context;
this.list = list;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.table_adapter, parent, false);
TextView name = (TextView) rowView.findViewById(R.id.name);
TextView pos = (TextView) rowView.findViewById(R.id.pos);
TextView points = (TextView) rowView.findViewById(R.id.points);
name.setText(list.get(position).getTeamName());
pos.setText(String.valueOf(position));
points.setText(String.valueOf(list.get(position).getPoints()));
return rowView;
}
}