zoukankan      html  css  js  c++  java
  • 2021.3.6

    在MainActivity里:

    package com.example.myaccountapp;

    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;

    import android.content.Intent;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ArrayAdapter;
    import android.widget.BaseAdapter;
    import android.widget.ImageButton;
    import android.widget.ListView;

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    public class MainActivity extends AppCompatActivity {


    private DBHelper helper;
    private ListView listView;
    private ImageButton Add;
    private List<costList>list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    initData();

    }

    private void initData() {
    list=new ArrayList<>();
    SQLiteDatabase db=helper.getReadableDatabase();
    Cursor cursor=db.query("account",null,null,null,null,
    null,null);
    while (cursor.moveToNext()){
    costList clist=new costList();//构造实例
    clist.set_id(cursor.getString(cursor.getColumnIndex("_id")));
    clist.setTitle(cursor.getString(cursor.getColumnIndex("Title")));
    clist.setDate(cursor.getString(cursor.getColumnIndex("Date")));
    clist.setMoney(cursor.getString(cursor.getColumnIndex("Money")));
    list.add(clist);
    }

    listView.setAdapter(new ListAdapter(this,list));
    db.close();
    }


    private void initView() {
    helper=new DBHelper(MainActivity.this);
    listView = findViewById(R.id.list_view);
    Add=findViewById(R.id.add);
    }


    public void addAccount(View view){//跳转
    Intent intent=new Intent(MainActivity.this,new_cost.class);
    startActivityForResult(intent,1);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==1&&resultCode==1)
    {
    this.initData();
    }
    }
    }

  • 相关阅读:
    zookeeper基本知识
    kafka常见问题
    模板设计模式
    Zookeeper的未授权访问漏洞解决
    Kubernetes准入控制器PodNodeSelector、PodTolerationRestriction
    Kubernetes 基于 Namespace 的物理队列实现,即Namespace下的Pod和Node的强绑定
    银行卡LUHM校验算法(C++)(转)
    银行卡LUHM校验算法(C++)(转)
    Unity导弹自动追踪算法(转)
    基于MicroChip ATmega4808的阿里云IOT连接开发套件方案(转)
  • 原文地址:https://www.cnblogs.com/SirNie/p/14911003.html
Copyright © 2011-2022 走看看