• 今日总结


    2021年2月9日:

    seting.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/grey_f3f3f3">
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="50dp">
    <ImageView
    android:id="@+id/setting_iv_back"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:src="@mipmap/it_back"
    android:layout_marginLeft="10dp"
    android:onClick="onClick"/>
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/setting"
    android:textStyle="bold"
    android:textSize="18sp"
    android:layout_centerInParent="true"/>
    </RelativeLayout>
    <TextView
    android:id="@+id/setting_tv_clear"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/clear_all"
    android:onClick="onClick"
    android:textSize="16sp"
    android:textStyle="bold"
    android:padding="15dp"
    android:background="@color/white"/>
    <View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/grey_7D7D7D"/>
    </LinearLayout>

    setingActivity:
    package com.example.jiatingruanjian;

    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Toast;

    import androidx.appcompat.app.AppCompatActivity;

    import com.example.jiatingruanjian.db.DBManager;


    public class SettingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);
    }

    public void onClick(View view) {
    switch (view.getId()) {
    case R.id.setting_iv_back:
    finish();
    break;
    case R.id.setting_tv_clear:
    showDeleteDialog();
    break;
    }
    }

    private void showDeleteDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("删除提示")
    .setMessage("您确定要删除所有记录么? 注意:删除后无法恢复,请慎重选择!")
    .setPositiveButton("取消",null)
    .setNegativeButton("确定", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    DBManager.deleteAllAccount();
    Toast.makeText(SettingActivity.this,"删除成功!",Toast.LENGTH_SHORT).show();
    }
    });
    builder.create().show();
    }
    }
  • 相关阅读:
    C语言基础10
    swift笔记06
    C语言基础09
    C语言基础08
    C语言基础07
    C语言基础06
    swift笔记05
    Swift笔记4
    C语言基础05
    [转]一个清华计算机博士生的退学申请
  • 原文地址:https://www.cnblogs.com/yitiaokuailedexiaojingyu/p/14394064.html
Copyright © 2020-2023  润新知