• 体温填报APP第五次开发


    这次一鼓作气完成了剩下的内容

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:orientation="vertical">
    
        <TextView
            android:id="@+id/tv_title"
            android:layout_width="150dp"
            android:layout_height="80dp"
            android:layout_marginLeft="10dp"
            android:layout_alignParentLeft="true"
            android:gravity="center"
            android:singleLine="true"
            android:textSize="35sp"
            android:text="costTitle"
            android:ellipsize="marquee" />
    
        <TextView
            android:id="@+id/tv_date"
            android:layout_width="wrap_content"
            android:layout_height="80dp"
            android:layout_toRightOf="@+id/tv_title"
            android:layout_marginLeft="15dp"
            android:textSize="20sp"
            android:gravity="center"
            android:text="costDate"/>
    
        <TextView
            android:id="@+id/tv_cost"
            android:layout_width="wrap_content"
            android:layout_height="80dp"
            android:text="30"
            android:textSize="30sp"
            android:layout_marginRight="20dp"
            android:layout_alignParentRight="true"
            android:gravity="center"/>
    </RelativeLayout>

    第二部分

    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;
        }
    }

    第三部分

    package com.example.jizhangben;
    
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    
    public class CostDB extends SQLiteOpenHelper {
    
        public static final String TABLE_NAME = "costs";
        public static final String MONEY = "money";
        public static final String DATE = "date";
        public static final String TITLE = "title";
    
        public CostDB(Context context) {
            super(context, "costs1", null, 1);
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL("create table if not exists "+ TABLE_NAME +"("+
                    "id integer primary key, "+
                    "title varchar, "+
                    "date varchar, "+
                    "money varchar)");
        }
        public void insertCost(costBean costBean1)
        {
            SQLiteDatabase database=getWritableDatabase();
            ContentValues cv=new ContentValues();
            cv.put(TITLE,costBean1.costTitle);
            cv.put(DATE,costBean1.costDate);
            cv.put(MONEY,costBean1.costMoney);
            database.insert("TABLE_NAME",null,cv);
        }
        public Cursor getAllCostData(){
            SQLiteDatabase database = getReadableDatabase();
            return database.query("TABLE_NAME",null,null,null,null,null,null);
        }
        public void deleteAllData(){
            SQLiteDatabase database=getWritableDatabase();
            database.delete("TABLE_NAME",null,null);
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    
        }
    }
  • 相关阅读:
    【LOJ #2290】「THUWC 2017」随机二分图(状压DP)
    【LOJ #2136】「ZJOI2015」地震后的幻想乡(状压DP)
    【CSP-S 2019模拟】题解
    异步编程补漏
    Git(七) 查漏补缺
    ES6(二) let const
    ES6(一) 数组
    JS判断对象是否存在
    Git(六)
    Git(五)
  • 原文地址:https://www.cnblogs.com/chaogehahaha/p/14915507.html
Copyright © 2020-2023  润新知