• 家庭记账本APP(4)


    
    

    package com.JIN;

    
    

    import androidx.appcompat.app.ActionBar;
    import androidx.appcompat.app.AppCompatActivity;

    
    

    import android.app.AlertDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.TextView;

    
    

    public class firstActivity extends AppCompatActivity {

    
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar=getSupportActionBar();
    actionBar.hide();
    setContentView(R.layout.activity_first);
    TextView t1=findViewById(R.id.add);
    TextView t2=findViewById(R.id.look);
    t2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent();
    intent.setClass(firstActivity.this, MainActivity.class);
    startActivity(intent);
    }
    });
    t1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent();
    intent.setClass(firstActivity.this, add_Activity.class);
    startActivity(intent);
    }
    });
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (((keyCode == KeyEvent.KEYCODE_BACK) ||
    (keyCode == KeyEvent.KEYCODE_HOME))
    && event.getRepeatCount() == 0) {

    
    

    dialog_Exit(firstActivity.this);

    
    

    }
    return false;

    
    


    }
    private void dialog_Exit(Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("确定要退出吗?");
    builder.setTitle("提示");
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setPositiveButton("确认",
    new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    System.exit(0);
    finish();
    }
    });

    
    

    builder.setNegativeButton("取消",
    new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    }
    });

    
    

    builder.create().show();
    }
    }

     
  • 相关阅读:
    电赛小结
    markdown小结
    一元运算符重载
    二维数组作为函数参数传递剖析(转载)
    C语言内存(转载)
    Effective C++ chapter1:Accustiming Yourself to C++
    C++ 模板
    const
    命令行参数
    AStar算法
  • 原文地址:https://www.cnblogs.com/ajinjinjin/p/14907420.html
Copyright © 2020-2023  润新知