package com.example.jizhangben;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;
class CostListAdapter extends BaseAdapter {
private List<costBean> mlist;
private Context mContext;
private LayoutInflater mlayoutInflater;
private Context context;
private Cursor cursor;
private LinearLayout layout;
public CostListAdapter(Context context, Cursor cursor) {
this.mContext = context;
this.cursor = cursor;
}
@Override
public int getCount() {
return cursor.getCount();
}
@Override
public Object getItem(int position) {
return cursor.getPosition();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
layout = (LinearLayout) inflater.inflate(R.layout.list_item, null);
TextView moneytv = layout.findViewById(R.id.tv_cost);
TextView datatv = layout.findViewById(R.id.tv_date);
TextView titletv = layout.findViewById(R.id.tv_title);
cursor.moveToPosition(position);
String money = cursor.getString(cursor.getColumnIndex("money"));
String data = cursor.getString(cursor.getColumnIndex("data"));
String title = cursor.getString(cursor.getColumnIndex("title"));
moneytv.setText(money);
datatv.setText(data);
titletv.setText(title);
return layout;
}
}