理财通app的设计与实现(二)

闲聊 闲聊 1469 人阅读 | 0 人回复

<
1、主界里


  1、界里结果

150233qvm9454fuq4gih7q.jpg

   2、筹办事情

  (1)正在工程包名上面创立一个文件夹 挑选工程的包名——左击——new——package——正在如今呈现的内乱容前面逃减输进 activity——单击 ok 按钮,即可天生 activity 文件夹。
  (2) 正在 activity 文件夹中创立 6 个子页里 挑选 activity 文件夹,左击——new——activity——Empty Activity——输进类 名:InComeActivity——单击 ok 按钮。
150233cuxx0rdrl0ld3q0h.png

   3、主界里规划 activity_main.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4.      xmlns:app="http://schemas.android.com/apk/res-auto"
  5.      xmlns:tools="http://schemas.android.com/tools"
  6.      android:layout_width="match_parent"
  7.      android:layout_height="match_parent"
  8.      android:orientation="vertical"
  9.      android:background="@drawable/welcomebg"
  10.      tools:context=".view.MainActivity">
  11.      <ImageButton
  12.          android:layout_width="match_parent"
  13.          android:layout_height="250dp"
  14.          android:background="@drawable/main_top"/>
  15.      <LinearLayout
  16.          android:layout_width="match_parent"
  17.          android:layout_height="wrap_content"
  18.          android:orientation="horizontal"
  19.          android:layout_marginTop="40dp"
  20.          android:gravity="center">
  21.          <Button
  22.              android:id="@+id/bt_newincome_main"
  23.              android:layout_width="90dp"
  24.              android:layout_height="90dp"
  25.              android:background="@drawable/new_pay_in"
  26.              android:layout_marginRight="50dp"/>
  27.          <Button
  28.              android:id="@+id/bt_incomedetail_main"
  29.              android:layout_width="90dp"
  30.              android:layout_height="90dp"
  31.              android:background="@drawable/my_pay_in"
  32.              android:layout_marginRight="50dp"/>
  33.          <Button
  34.              android:id="@+id/bt_newpay_main"
  35.              android:layout_width="90dp"
  36.              android:layout_height="90dp"
  37.              android:background="@drawable/new_pay_out" />
  38.      </LinearLayout>
  39.      <LinearLayout
  40.          android:layout_width="match_parent"
  41.          android:layout_height="wrap_content"
  42.          android:orientation="horizontal"
  43.          android:layout_marginTop="20dp"
  44.          android:gravity="center">
  45.          <TextView
  46.              android:layout_width="wrap_content"
  47.              android:layout_height="wrap_content"
  48.              android:text="新删支出"
  49.              android:textSize="15sp"
  50.              android:textColor="#ffffff"
  51.              android:layout_marginRight="80dp"/>
  52.          <TextView
  53.              android:layout_width="wrap_content"
  54.              android:layout_height="wrap_content"
  55.              android:text="支出明细"
  56.              android:textSize="15sp"
  57.              android:textColor="#ffffff"
  58.              android:layout_marginRight="80dp"/>
  59.          <TextView
  60.              android:layout_width="wrap_content"
  61.              android:layout_height="wrap_content"
  62.              android:text="新删收入"
  63.              android:textSize="15sp"
  64.              android:textColor="#ffffff"/>
  65.      </LinearLayout>
  66.      <LinearLayout
  67.          android:layout_width="match_parent"
  68.          android:layout_height="wrap_content"
  69.          android:orientation="horizontal"
  70.          android:layout_marginTop="40dp"
  71.          android:gravity="center">
  72.          <Button
  73.              android:id="@+id/bt_paydetail_main"
  74.              android:layout_width="90dp"
  75.              android:layout_height="90dp"
  76.              android:background="@drawable/my_pay_out"
  77.              android:layout_marginRight="50dp"/>
  78.          <Button
  79.              android:id="@+id/bt_dataanalyse_main"
  80.              android:layout_width="90dp"
  81.              android:layout_height="90dp"
  82.              android:background="@drawable/data_administration"
  83.              android:layout_marginRight="50dp"/>
  84.          <Button
  85.              android:id="@+id/bt_syssetting_main"
  86.              android:layout_width="90dp"
  87.              android:layout_height="90dp"
  88.              android:background="@drawable/sys_setting" />
  89.      </LinearLayout>
  90.      <LinearLayout
  91.          android:layout_width="match_parent"
  92.          android:layout_height="wrap_content"
  93.          android:orientation="horizontal"
  94.          android:layout_marginTop="20dp"
  95.          android:gravity="center">
  96.          <TextView
  97.              android:layout_width="wrap_content"
  98.              android:layout_height="wrap_content"
  99.              android:text="收入明细"
  100.              android:textSize="15sp"
  101.              android:textColor="#ffffff"
  102.              android:layout_marginRight="80dp"/>
  103.          <TextView
  104.              android:layout_width="wrap_content"
  105.              android:layout_height="wrap_content"
  106.              android:text="数据阐发"
  107.              android:textSize="15sp"
  108.              android:textColor="#ffffff"
  109.              android:layout_marginRight="80dp"/>
  110.          <TextView
  111.              android:layout_width="wrap_content"
  112.              android:layout_height="wrap_content"
  113.              android:text="体系设置"
  114.              android:textSize="15sp"
  115.              android:textColor="#ffffff"/>
  116.      </LinearLayout>
  117. </LinearLayout>
复造代码
   4、主界里类文件 MainActivity.java

  1. public class MainActivity extends AppCompatActivity {
  2. //界说工具
  3.      Button bt_newincome,bt_incomedetail,btn_newpay,btn_paydetail,bt_dataanalyse,btn_setting;
  4.      @Override
  5.      protected void onCreate(Bundle savedInstanceState) {
  6.          super.onCreate(savedInstanceState);
  7.          setContentView(R.layout.activity_main);
  8.          // 绑定控件
  9.          initView();
  10.          //按钮单击变乱
  11.          btnOnClick();
  12.      }
  13.      // 绑定控件--------------------------代码
  14.      private void initView() {
  15.          bt_newincome=findViewById(R.id.bt_newincome_main);
  16.          bt_incomedetail=findViewById(R.id.bt_incomedetail_main);
  17.          btn_newpay=findViewById(R.id.bt_newpay_main);
  18.          btn_paydetail=findViewById(R.id.bt_paydetail_main);
  19.          bt_dataanalyse=findViewById(R.id.bt_dataanalyse_main);
  20.          btn_setting=findViewById(R.id.bt_syssetting_main);
  21.      }
  22.      //按钮单击变乱-------------------代码
  23.      private void btnOnClick() {
  24.          bt_newincome.setOnClickListener(new View.OnClickListener() {
  25.              @Override
  26.              public void onClick(View v) {
  27.                  Intent intent=new Intent(MainActivity.this, NewInComeActivity.class);
  28.                  startActivity(intent);
  29.              }
  30.          });
  31.          bt_incomedetail.setOnClickListener(new View.OnClickListener() {
  32.              @Override
  33.              public void onClick(View v) {
  34.                  Intent intent=new Intent(MainActivity.this, InComeDetailActivity.class);
  35.                  startActivity(intent);
  36.              }
  37.          });
  38.          btn_newpay.setOnClickListener(new View.OnClickListener() {
  39.              @Override
  40.              public void onClick(View v) {
  41.                  Intent intent=new Intent(MainActivity.this, NewPayActivity.class);
  42.                  startActivity(intent);
  43.              }
  44.          });
  45.          btn_paydetail.setOnClickListener(new View.OnClickListener() {
  46.              @Override
  47.              public void onClick(View v) {
  48.                  Intent intent=new Intent(MainActivity.this, PayDetailActivity.class);
  49.                  startActivity(intent);
  50.              }
  51.          });
  52.          bt_dataanalyse.setOnClickListener(new View.OnClickListener() {
  53.              @Override
  54.              public void onClick(View v) {
  55.                  Intent intent=new Intent(MainActivity.this, DataAnalyseActivity.class);
  56.                  startActivity(intent);
  57.              }
  58.          });
  59.          btn_setting.setOnClickListener(new View.OnClickListener() {
  60.              @Override
  61.              public void onClick(View v) {
  62.                  Intent intent=new Intent(MainActivity.this, SysSettingActivity.class);
  63.                  startActivity(intent);
  64.              }
  65.          });
  66.      }
  67. }
复造代码
   5、代码讲解

      项目中利用到了ImageButton,可是给图片设置详细尺微暇后发明仍是本来的巨细,后来将ImageButton酿成ImageView就能够了。起首我们从源码的角度去看一下二者的区分。
  ImageView担当的是View         ImageButton担当的是ImageView
      我们去阐发一下几种差别状况下二者之间的不同。
      1、二者均没有设置详细的宽下
      其显现结果出有甚么不同。
      2、设置了详细的宽下。
      ImageView会根据详细的宽下尺微暇发作变革,可是ImageButton只会显现图片的本初像素巨细。假如给ImageButton设置了scaleType属性就能够告竣ImageView的结果,可是图片会得实。
      3、设置布景挑选器。
      ImageView要念使挑选器结果见效,需求让控件得到核心。需求减上android:clickable=true;
      ImageButton便没有需求处理,由于正在源码中ImageButton的机关函数中曾经设置过了setFocusable(true)。
      4、设置background无详细宽下。
       结果一样。
      5、设置background有详细宽下。
       结果一样。取src差别的是,二者均跟着详细宽多发死改动。
2、新删支出界里

  1、界里结果

150234q9op6pg1oovvlggv.jpg

  2、 前期筹办

    (1)为 spinner 控件筹办数据

  (1)正在 values 下新建一个 xml 文件,以下图:
  
150234ibvcv2xxtvrkm1mc.jpg

   (2)正在文件中增加两个字符串数
  
150234onpnpcfcj1gbcnrd.jpg

   (3)正在规划文件用 entries 属性援用字符串数组
  
150235tqvw5qjawa6l2a16.jpg

    (2)正在数据库类文件中增加支出表战收入表

150235o9lughinnhbsnaja.jpg

  1. //创立一个支出表
  2. db.execSQL("create table in_come(id integer primary key autoincrement,inmoney double,intime varchar(20),intype varchar(30),inpayer varchar(100),inremark varchar(500))");
复造代码
  1. //创立一个收入表
  2. db.execSQL("create table out_pay(id integer primary key autoincrement,outmoney double,outtime varchar(20),outtype varchar(30),outpayee varchar(100),outremark varchar(500))");
复造代码
  3、新删支出规划界里 activity_new_income.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.      xmlns:app="http://schemas.android.com/apk/res-auto"
  4.      xmlns:tools="http://schemas.android.com/tools"
  5.      android:layout_width="match_parent"
  6.      android:layout_height="match_parent"
  7.      android:orientation="vertical"
  8.      android:background="@drawable/new_income_bg"
  9.      tools:context=".activity.NewInComeActivity">
  10.      <LinearLayout
  11.          android:layout_width="match_parent"
  12.          android:layout_height="wrap_content"
  13.          android:orientation="horizontal"
  14.          android:layout_marginTop="220dp"
  15.          android:layout_marginLeft="30dp"
  16.          android:layout_marginRight="30dp">
  17.          <TextView
  18.              android:layout_width="wrap_content"
  19.              android:layout_height="wrap_content"
  20.              android:text="金 额:"
  21.              android:textColor="#000000"
  22.              android:textSize="20sp"
  23.              android:textStyle="bold"/>
  24.          <EditText
  25.              android:id="@+id/et_money_newin"
  26.              android:layout_width="match_parent"
  27.              android:layout_height="wrap_content"
  28.              android:hint="0.00"
  29.              android:textColor="#000000"
  30.              android:textSize="20sp"
  31.              android:textStyle="bold"
  32.              android:gravity="center"/>
  33.      </LinearLayout>
  34.      <LinearLayout
  35.          android:layout_width="match_parent"
  36.          android:layout_height="wrap_content"
  37.          android:orientation="horizontal"
  38.          android:layout_marginTop="10dp"
  39.          android:layout_marginLeft="30dp"
  40.          android:layout_marginRight="30dp">
  41.          <TextView
  42.              android:layout_width="wrap_content"
  43.              android:layout_height="wrap_content"
  44.              android:text="日 期:"
  45.              android:textColor="#000000"
  46.              android:textSize="20sp"
  47.              android:textStyle="bold"/>
  48.          <EditText
  49.              android:id="@+id/et_time_newin"
  50.              android:layout_width="match_parent"
  51.              android:layout_height="wrap_content"
  52.              android:hint="2020-05-12"
  53.              android:textColor="#000000"
  54.              android:textSize="20sp"
  55.              android:textStyle="bold"
  56.              android:gravity="center"/>
  57.      </LinearLayout>
  58.      <LinearLayout
  59.          android:layout_width="match_parent"
  60.          android:layout_height="wrap_content"
  61.          android:orientation="horizontal"
  62.          android:layout_marginTop="10dp"
  63.          android:layout_marginLeft="30dp"
  64.          android:layout_marginRight="30dp">
  65.          <TextView
  66.              android:layout_width="wrap_content"
  67.              android:layout_height="wrap_content"
  68.              android:text="类 型:"
  69.              android:textColor="#000000"
  70.              android:textSize="20sp"
  71.              android:textStyle="bold"/>
  72.          <Spinner
  73.              android:id="@+id/sp_type_newin"
  74.              android:layout_width="match_parent"
  75.              android:layout_height="wrap_content"
  76.              android:entries="@array/incometype"/>
  77.      </LinearLayout>
  78.      <LinearLayout
  79.          android:layout_width="match_parent"
  80.          android:layout_height="wrap_content"
  81.          android:orientation="horizontal"
  82.          android:layout_marginTop="10dp"
  83.          android:layout_marginLeft="30dp"
  84.          android:layout_marginRight="30dp">
  85.          <TextView
  86.              android:layout_width="wrap_content"
  87.              android:layout_height="wrap_content"
  88.              android:text="付款圆:"
  89.              android:textColor="#000000"
  90.              android:textSize="20sp"
  91.              android:textStyle="bold"/>
  92.          <EditText
  93.              android:id="@+id/et_payer_newin"
  94.              android:layout_width="match_parent"
  95.              android:layout_height="wrap_content"
  96.              android:hint="海明有限公司"
  97.              android:textColor="#000000"
  98.              android:textSize="20sp"
  99.              android:textStyle="bold"
  100.              android:gravity="center"/>
  101.      </LinearLayout>
  102.      <LinearLayout
  103.          android:layout_width="match_parent"
  104.          android:layout_height="wrap_content"
  105.          android:orientation="horizontal"
  106.          android:layout_marginTop="10dp"
  107.          android:layout_marginLeft="30dp"
  108.          android:layout_marginRight="30dp">
  109.          <TextView
  110.              android:layout_width="wrap_content"
  111.              android:layout_height="wrap_content"
  112.              android:text="备 注:"
  113.              android:textColor="#000000"
  114.              android:textSize="20sp"
  115.              android:textStyle="bold"/>
  116.          <EditText
  117.              android:id="@+id/et_remark_newin"
  118.              android:layout_width="match_parent"
  119.              android:layout_height="wrap_content"
  120.              android:hint="长途手艺指点费"
  121.              android:textColor="#000000"
  122.              android:textSize="20sp"
  123.              android:textStyle="bold"
  124.              android:gravity="center"/>
  125.      </LinearLayout>
  126.      <Button
  127.          android:id="@+id/bt_save_newin"
  128.          android:layout_width="match_parent"
  129.          android:layout_height="wrap_content"
  130.          android:text="保留"
  131.          android:textSize="20sp"
  132.          android:textColor="#ffffff"
  133.          android:layout_marginLeft="60dp"
  134.          android:layout_marginRight="60dp"
  135.          android:background="@drawable/btn_style_one"
  136.          android:layout_marginTop="40dp"/>
  137.      <Button
  138.          android:id="@+id/bt_cancel_newin"
  139.          android:layout_width="match_parent"
  140.          android:layout_height="wrap_content"
  141.          android:text="打消"
  142.          android:textSize="20sp"
  143.          android:textColor="#000000"
  144.          android:layout_marginLeft="60dp"
  145.          android:layout_marginRight="60dp"
  146.          android:background="@drawable/btn_style_two"
  147.          android:layout_marginTop="20dp"/>
  148. </LinearLayout>
复造代码
  4、新删支出类文件 NewInComeActivity.java

  1. public class NewInComeActivity extends AppCompatActivity {
  2. //1 界说工具
  3.      EditText et_money,et_time,et_payer,et_remark;
  4.      Spinner sp_type;
  5.      Button bt_sava,bt_cancel;
  6.      MyDBHelper mhelper;
  7.      SQLiteDatabase db;
  8.      @Override
  9.      protected void onCreate(Bundle savedInstanceState) {
  10.          super.onCreate(savedInstanceState);
  11.          setContentView(R.layout.activity_new_in_come);
  12.          //2 绑定控件
  13.          initView();
  14.          //3 保留按钮功用的完成
  15.          btnSave();
  16.          //4 打消按钮功用的完成
  17.          btnCancel();
  18.      }
  19.      //2 绑定控件-------------------代码
  20.      private void initView() {
  21.          et_money=findViewById(R.id.et_money_newin);
  22.          et_time=findViewById(R.id.et_time_newin);
  23.          sp_type=findViewById(R.id.sp_type_newin);
  24.          et_payer=findViewById(R.id.et_payer_newin);
  25.          et_remark=findViewById(R.id.et_remark_newin);
  26.          bt_sava=findViewById(R.id.bt_save_newin);
  27.          bt_cancel=findViewById(R.id.bt_cancel_newin);
  28.          mhelper=new MyDBHelper(NewInComeActivity.this);
  29.          db=mhelper.getWritableDatabase();
  30.      }
  31.      //3 保留按钮功用的完成--------代码
  32.      private void btnSave() {
  33.          bt_sava.setOnClickListener(new View.OnClickListener() {
  34.              @Override
  35.              public void onClick(View v) {
  36.                  //获得输进的内乱容保留到数据库的支出表中
  37.                  ContentValues values=new ContentValues();
  38.                  values.put("inmoney",et_money.getText().toString());
  39.                  values.put("intime",et_time.getText().toString());
  40.                  values.put("intype",sp_type.getSelectedItem().toString());
  41.                  values.put("inpayer",et_payer.getText().toString());
  42.                  values.put("inremark",et_remark.getText().toString());
  43.                  db.insert("in_come",null,values);
  44.                  Toast.makeText(NewInComeActivity.this,"保留胜利",Toast.LENGTH_SHORT).show();
  45.                  //革新本页里
  46.                  Intent intent=new Intent(NewInComeActivity.this,NewInComeActivity.class);
  47.                  startActivity(intent);
  48.                  finish();
  49.              }
  50.          });
  51.      }
  52.      //4 打消按钮功用的完成--------代码
  53.      private void btnCancel() {
  54.          bt_cancel.setOnClickListener(new View.OnClickListener() {
  55.              @Override
  56.              public void onClick(View v) {
  57.                  Intent intent=new Intent(NewInComeActivity.this, MainActivity.class);
  58.                  startActivity(intent);
  59.                  finish();
  60.              }   
  61.          });
  62.      }
  63. }
复造代码
3、新删收入界里

  1、界里结果

150235dzar0l50rer5cq8d.jpg

   3、新删收入规划界里 activity_new_pay.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.      xmlns:app="http://schemas.android.com/apk/res-auto"
  4.      xmlns:tools="http://schemas.android.com/tools"
  5.      android:layout_width="match_parent"
  6.      android:layout_height="match_parent"
  7.      android:orientation="vertical"
  8.      android:background="@drawable/new_income_bg"
  9.      tools:context=".activity.NewInComeActivity">
  10.      <LinearLayout
  11.          android:layout_width="match_parent"
  12.          android:layout_height="wrap_content"
  13.          android:orientation="horizontal"
  14.          android:layout_marginTop="220dp"
  15.          android:layout_marginLeft="30dp"
  16.          android:layout_marginRight="30dp">
  17.          <TextView
  18.              android:layout_width="wrap_content"
  19.              android:layout_height="wrap_content"
  20.              android:text="金 额:"
  21.              android:textColor="#000000"
  22.              android:textSize="20sp"
  23.              android:textStyle="bold"/>
  24.          <EditText
  25.              android:id="@+id/et_money_newin"
  26.              android:layout_width="match_parent"
  27.              android:layout_height="wrap_content"
  28.              android:hint="0.00"
  29.              android:textColor="#000000"
  30.              android:textSize="20sp"
  31.              android:textStyle="bold"
  32.              android:gravity="center"/>
  33.      </LinearLayout>
  34.      <LinearLayout
  35.          android:layout_width="match_parent"
  36.          android:layout_height="wrap_content"
  37.          android:orientation="horizontal"
  38.          android:layout_marginTop="10dp"
  39.          android:layout_marginLeft="30dp"
  40.          android:layout_marginRight="30dp">
  41.          <TextView
  42.              android:layout_width="wrap_content"
  43.              android:layout_height="wrap_content"
  44.              android:text="日 期:"
  45.              android:textColor="#000000"
  46.              android:textSize="20sp"
  47.              android:textStyle="bold"/>
  48.          <EditText
  49.              android:id="@+id/et_time_newin"
  50.              android:layout_width="match_parent"
  51.              android:layout_height="wrap_content"
  52.              android:hint="2020-05-12"
  53.              android:textColor="#000000"
  54.              android:textSize="20sp"
  55.              android:textStyle="bold"
  56.              android:gravity="center"/>
  57.      </LinearLayout>
  58.      <LinearLayout
  59.          android:layout_width="match_parent"
  60.          android:layout_height="wrap_content"
  61.          android:orientation="horizontal"
  62.          android:layout_marginTop="10dp"
  63.          android:layout_marginLeft="30dp"
  64.          android:layout_marginRight="30dp">
  65.          <TextView
  66.              android:layout_width="wrap_content"
  67.              android:layout_height="wrap_content"
  68.              android:text="类 型:"
  69.              android:textColor="#000000"
  70.              android:textSize="20sp"
  71.              android:textStyle="bold"/>
  72.          <Spinner
  73.              android:id="@+id/sp_type_newin"
  74.              android:layout_width="match_parent"
  75.              android:layout_height="wrap_content"
  76.              android:entries="@array/incometype"/>
  77.      </LinearLayout>
  78.      <LinearLayout
  79.          android:layout_width="match_parent"
  80.          android:layout_height="wrap_content"
  81.          android:orientation="horizontal"
  82.          android:layout_marginTop="10dp"
  83.          android:layout_marginLeft="30dp"
  84.          android:layout_marginRight="30dp">
  85.          <TextView
  86.              android:layout_width="wrap_content"
  87.              android:layout_height="wrap_content"
  88.              android:text="付款圆:"
  89.              android:textColor="#000000"
  90.              android:textSize="20sp"
  91.              android:textStyle="bold"/>
  92.          <EditText
  93.              android:id="@+id/et_payer_newin"
  94.              android:layout_width="match_parent"
  95.              android:layout_height="wrap_content"
  96.              android:hint="海明有限公司"
  97.              android:textColor="#000000"
  98.              android:textSize="20sp"
  99.              android:textStyle="bold"
  100.              android:gravity="center"/>
  101.      </LinearLayout>
  102.      <LinearLayout
  103.          android:layout_width="match_parent"
  104.          android:layout_height="wrap_content"
  105.          android:orientation="horizontal"
  106.          android:layout_marginTop="10dp"
  107.          android:layout_marginLeft="30dp"
  108.          android:layout_marginRight="30dp">
  109.          <TextView
  110.              android:layout_width="wrap_content"
  111.              android:layout_height="wrap_content"
  112.              android:text="备 注:"
  113.              android:textColor="#000000"
  114.              android:textSize="20sp"
  115.              android:textStyle="bold"/>
  116.          <EditText
  117.              android:id="@+id/et_remark_newin"
  118.              android:layout_width="match_parent"
  119.              android:layout_height="wrap_content"
  120.              android:hint="长途手艺指点费"
  121.              android:textColor="#000000"
  122.              android:textSize="20sp"
  123.              android:textStyle="bold"
  124.              android:gravity="center"/>
  125.      </LinearLayout>
  126.      <Button
  127.          android:id="@+id/bt_save_newin"
  128.          android:layout_width="match_parent"
  129.          android:layout_height="wrap_content"
  130.          android:text="保留"
  131.          android:textSize="20sp"
  132.          android:textColor="#ffffff"
  133.          android:layout_marginLeft="60dp"
  134.          android:layout_marginRight="60dp"
  135.          android:background="@drawable/btn_style_one"
  136.          android:layout_marginTop="40dp"/>
  137.      <Button
  138.          android:id="@+id/bt_cancel_newin"
  139.          android:layout_width="match_parent"
  140.          android:layout_height="wrap_content"
  141.          android:text="打消"
  142.          android:textSize="20sp"
  143.          android:textColor="#000000"
  144.          android:layout_marginLeft="60dp"
  145.          android:layout_marginRight="60dp"
  146.          android:background="@drawable/btn_style_two"
  147.          android:layout_marginTop="20dp"/>
  148. </LinearLayout>
复造代码
 4、新删收入类文件 NewPayActivity.java

  1. public class NewPayActivity extends AppCompatActivity {
  2. //界说工具
  3. EditText et_money,et_time,et_payer,et_remark;
  4.      Spinner sp_type;
  5.      Button bt_sava,bt_cancel;
  6.      MyDBHelper mhelper;
  7.      SQLiteDatabase db;
  8.      @Override
  9.      protected void onCreate(Bundle savedInstanceState) {
  10.          super.onCreate(savedInstanceState);
  11.          setContentView(R.layout.activity_new_pay);
  12.          //2 绑定控件
  13.          initView();
  14.          //3 保留按钮功用的完成
  15.          btnSave();
  16.          //4 打消按钮功用的完成
  17.          btnCancel();
  18.      }
  19.      //2 绑定控件-------------------代码
  20.      private void initView() {
  21.          et_money=findViewById(R.id.et_money_newout);
  22.          et_time=findViewById(R.id.et_time_newout);
  23.          sp_type=findViewById(R.id.sp_type_newout);
  24.          et_payer=findViewById(R.id.et_payer_newout);
  25.          et_remark=findViewById(R.id.et_remark_newout);
  26.          bt_sava=findViewById(R.id.bt_save_newout);
  27.          bt_cancel=findViewById(R.id.bt_cancel_newout);
  28.          mhelper=new MyDBHelper(NewPayActivity.this);
  29.          db=mhelper.getWritableDatabase();
  30.      }
  31.      //3 保留按钮功用的完成--------代码
  32.      private void btnSave() {
  33.          bt_sava.setOnClickListener(new View.OnClickListener() {
  34.              @Override
  35.              public void onClick(View v) {
  36.                  //获得输进的内乱容保留到数据库的支出表中
  37.                  ContentValues values=new ContentValues();
  38.                  values.put("outmoney",et_money.getText().toString());
  39.                  values.put("outtime",et_time.getText().toString());
  40.                  values.put("outtype",sp_type.getSelectedItem().toString());
  41.                  values.put("outpayee",et_payer.getText().toString());
  42.                  values.put("outremark",et_remark.getText().toString());
  43.                  db.insert("pay_out",null,values);
  44.                  Toast.makeText(NewPayActivity.this,"保留胜利",Toast.LENGTH_SHORT).show();
  45.                  //革新本页里
  46.                  Intent intent=new Intent(NewPayActivity.this,NewPayActivity.class);
  47.                  startActivity(intent);
  48.                  finish();
  49.              }
  50.          });
  51.      }
  52.      //4 打消按钮功用的完成--------代码
  53.      private void btnCancel() {
  54.          bt_cancel.setOnClickListener(new View.OnClickListener() {
  55.              @Override
  56.              public void onClick(View v) {
  57.                  Intent intent=new Intent(NewPayActivity.this, MainActivity.class);
  58.                  startActivity(intent);
  59.                  finish();
  60.              }
  61.          });
  62.      }
  63. }
复造代码








免责声明:假如进犯了您的权益,请联络站少,我们会实时删除侵权内乱容,感谢协作!
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,按照目前互联网开放的原则,我们将在不通知作者的情况下,转载文章;如果原文明确注明“禁止转载”,我们一定不会转载。如果我们转载的文章不符合作者的版权声明或者作者不想让我们转载您的文章的话,请您发送邮箱:Cdnjson@163.com提供相关证明,我们将积极配合您!
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并自负版权等法律责任。
回复 关闭延时

使用道具 举报

 
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则