JAVA日报
app开发(ThirdActivity)
package com.example.jizhang;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import dao.userdao;
public class ThirdActivity extends AppCompatActivity implements View.OnClickListener {
private String str="";
private EditText editText1;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
findViewById(R.id.btn5).setOnClickListener(this);
InitData();
}
private void InitData(){
editText1 = (EditText) findViewById(R.id.edt_date3);
}
@Override
public void onClick(View v) {
str=editText1.getText().toString();
userdao userDao=userdao.getInstance(getApplicationContext());
if (str.length()==0) {
Toast.makeText(getApplicationContext(), "请输入日期", Toast.LENGTH_SHORT).show();
return;
} else {
userDao.delete(str);
Toast.makeText(getApplicationContext(), "删除成功", Toast.LENGTH_SHORT).show();
Intent intent=new Intent();
intent.setClass(getApplicationContext(),MainActivity.class);
startActivity(intent);
return;
}
}
}