zoukankan      html  css  js  c++  java
  • 家庭记账本(六)

    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;
    }
    }
  • 相关阅读:
    进程的实践与练习2
    士兵队列训练问题
    大数相加
    Ignatius and the Princess II
    Parentheses Balance (括号平衡)---栈
    简单计算器
    C++全排列函数next_permutation()和prev_permutation()
    黑白图像
    9*9乘法表
    输入5 个数按从小到大的顺序输出
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/14912776.html
Copyright © 2011-2022 走看看