首页 > 其他分享 >6.13

6.13

时间:2024-06-18 09:48:09浏览次数:21  
标签:6.13 void public new import android builder

package com.example.my2mysql.activiy;

import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.example.my2mysql.Pojo.Plan;
import com.example.my2mysql.Pojo.PlanDAO;
import com.example.my2mysql.R;
import com.example.my2mysql.tool.MyAdapter;

import java.util.List;

public class APPactivity extends AppCompatActivity {
private ListView mLvPlans;
private List<Plan> mDataList;
private PlanDAO mPlanDAO;

@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appactivity);

mLvPlans = findViewById(R.id.listView);
mPlanDAO = new PlanDAO(this);
mPlanDAO.open();




mDataList = mPlanDAO.getAllPlans();
MyAdapter adapter = new MyAdapter(this, mDataList);
mLvPlans.setAdapter(adapter);

setupButtons();
}



private void setupButtons(){
Button btnAdd = findViewById(R.id.btnAdd);
Button btnDelete = findViewById(R.id.btnDelete);
Button btnUpdate = findViewById(R.id.btnUpdate);

btnAdd.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
showAddPlanDialog();
}
});

btnDelete.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
showDeletePlanDialog();
}
});

btnUpdate.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
showUpdatePlanDialog();
}
});
}

private void showAddPlanDialog() {
} AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Add Plan");
builder.setMessage("Enter plan details:");

final EditText input = new EditText(this);
builder.setView(input);

builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String planDetails = input.getText().toString();
if (!planDetails.isEmpty()) {
Plan newPlan = new Plan(); // Assuming isDone is initially set to false
mPlanDAO.addPlan(newPlan);
updateListView();
} else {
Toast.makeText(APPactivity.this, "Plan details cannot be empty", Toast.LENGTH_SHORT).show();
}
}
});

builder.setNegativeButton("Cancel", null);
builder.show();
}

private void showDeletePlanDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Delete Plan");
builder.setMessage("Enter plan ID to delete:");

final EditText input = new EditText(this);
builder.setView(input);

builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String planId = input.getText().toString();
if (!planId.isEmpty()) {
mPlanDAO.deletePlan(Integer.parseInt(planId));
updateListView();
} else {
Toast.makeText(APPactivity.this, "Plan ID cannot be empty", Toast.LENGTH_SHORT).show();
}
}
});

builder.setNegativeButton("Cancel", null);
builder.show();
}

private void showUpdatePlanDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Update Plan");
builder.setMessage("Enter plan ID and new details:");

final EditText inputId = new EditText(this);
inputId.setHint("Plan ID");
final EditText inputDetails = new EditText(this);
inputDetails.setHint("New Plan Details");

LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(inputId);
layout.addView(inputDetails);
builder.setView(layout);

builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String planId = inputId.getText().toString();
String newDetails = inputDetails.getText().toString();
if (!planId.isEmpty() && !newDetails.isEmpty()) {
Plan updatedPlan = new Plan(Integer.parseInt(planId), newDetails, false); // Assuming Plan constructor takes id, details and isDone
mPlanDAO.updatePlan(updatedPlan);
updateListView();
} else {
Toast.makeText(APPactivity.this, "Plan ID and new details cannot be empty", Toast.LENGTH_SHORT).show();
}
}
});

builder.setNegativeButton("Cancel", null);
builder.show();
}

private void updateListView() {
mDataList.clear();
mDataList.addAll(mPlanDAO.getAllPlans());
((MyAdapter) mLvPlans.getAdapter()).notifyDataSetChanged();
}

@Override
protected void onDestroy() {
super.onDestroy();
mPlanDAO.close();
}
}
package com.example.my2mysql.activiy;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.my2mysql.R;
import com.example.my2mysql.tool.okhttp3manager;

public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity";
private Button login;
private Button register;
private EditText et_id;
private EditText et_passwd;
private Handler handler;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_login);

handler = new Handler(Looper.getMainLooper());
initview();
}

public void initview() {
et_id = findViewById(R.id.lg_id);
et_passwd = findViewById(R.id.lg_password);
login = findViewById(R.id.bt_login);
register = findViewById(R.id.bt_register);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(LoginActivity.this, registerActivity.class);
startActivity(intent);
finish();
}
});

login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userId = et_id.getText().toString();
String password = et_passwd.getText().toString();

new Thread() {
@Override
public void run() {
okhttp3manager.login(userId, password, new okhttp3manager.LoginCallback() {
@Override
public void LoginSuccess(int auth) {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_SHORT).show();
}
});

if (auth == 0) {
handler.post(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LoginActivity.this, MainActivity2.class);
startActivity(intent);
finish();
}
});
}
}

@Override
public void LoginFailure(final String errorMessage) {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, errorMessage, Toast.LENGTH_SHORT).show();
}
});
}
});
}
}.start();
}
});
}
}
package com.example.my2mysql.activiy;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.my2mysql.R;
import com.example.my2mysql.activiy.registerActivity;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);


}





}

标签:6.13,void,public,new,import,android,builder
From: https://www.cnblogs.com/wcy1111/p/18253706

相关文章

  • 6.13
      五、实验过程:1、基本配置1)三层交换机的基本配置Switch(config)#vlan10Switch(config-vlan)#Switch(config-vlan)#Switch(config-vlan)#endSwitch#configureterminalEnterconfigurationcommands,oneperline.EndwithCNTL/Z.Switch(config)#interfaceFastE......
  • 6.13
    python错题管理系统importtkinterastkfromtkinterimportttkimportpymysqlclassWrongQuestionManagementSystem:def__init__(self):self.root=tk.Tk()self.root.title("错题本信息管理系统")self.create_main_page()s......
  • 6.13
    今日学习总结学习时间1.5h代码如下packagecom.app.chapter04;importandroid.content.ComponentName;importandroid.content.Intent;importandroid.os.Bundle;importandroid.util.Log;importandroid.view.View;importandroidx.activity.EdgeToEdge;importandroidx.appco......
  • 6.13安卓开发日记57
    今天完成工程数学作业实验五实验五:MATLAB最优化工具箱的使用一、实验目的通过一个农业生产计划优化安排的实例求解,培养学生解决实际线性规划问题的初步能力;熟悉线性规划的建模过程;掌握Matlab优化工具箱中线性规划函数的调用。通过一个投资组合优化问题的实例求解,培养学生解决......
  • 6.13学习内容
    今天完成了计算机网络的实验三 综合性训练(搭建中小企业园区网)一、实验目的:1.通过对网络设备的连通和对拓扑的分析,加深对常见典型局域网拓扑的理解;2.通过路由建立起网络之间的连接,了解网络路由的设计与配置;3.进一步熟悉交换机、路由器的基本操作命令。二、实验设备:六个PC,两......
  • 6.13-栈与队列
    基础知识首先大家要知道栈和队列是STL(C++标准库)里面的两个数据结构。C++标准库是有多个版本的,要知道我们使用的STL是哪个版本,才能知道对应的栈和队列的实现原理。那么来介绍一下,三个最为普遍的STL版本:HPSTL其他版本的C++STL,一般是以HPSTL为蓝本实现出来的,HPSTL是C++S......
  • 6.13模拟赛题解
    前面是题解,后面是垃圾话。T1P1541[NOIP2010提高组]乌龟棋没脑子直接设\(f_{p,i,j,k,w}\),为走到\(p\),还剩\(1,2,3,4\)牌各\(i,j,k,w\)张,\(9\cdot10^8\),发现到一个点只要三种牌的数量确定,最后一种也确定了,所以直接设\(f_{p,i,j,k}\)表示三种牌的就行,大力DP即可。T......
  • 6.13API接口服务类漏洞探针
    ip地址解析:www.x.x.x.com,对应网站目录为d:/wwwroot/xiaodi/而127.x.x.x,对应网站目录为d:/wwwroot/,可能存在网站备份文件zip,所以ip网址端口都的扫描;协议端弱口令爆破:超级弱口令检查工具;端口服务安全问题(用于无思路时)思路:利用探针对端口探测后,对口令安全、Web漏洞、中间......
  • 2024.6.13
    2024.6.13【痛苦的,热烈的,误解的,无解的,快乐的,解脱的】Thursday五月初八<theme=oi-"gametheory">P4018Roy&October之取石子Roy&October之取石子题目背景Roy和October两人在玩一个取石子的游戏。题目描述游戏规则是这样的:共有\(n\)个石子,两人每次都只能取\(p^......
  • 文献精读_2024.06.13
    Universalandextensiblelanguage-visionmodelsfororgansegmentationandtumordetectionfromabdominalcomputedtomography来源:https://doi.org/10.1016/j.media.2024.103226GitHub仓库:https://github.com/ljwztc/CLIP-Driven-Universal-Model第一眼,仓库上面放......