private void btnModify(){ bt_modify.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { String ypwd=et_ypwd.getText().toString(); String xpwd=et_xpwd.getText().toString(); String zxpwd=et_zxpwd.getText().toString(); if(ypwd.equals("")){ Toast.makeText(SysSettingActivity.this, "请输入原始密码", Toast.LENGTH_SHORT).show(); }else if(!ypwd.equalsIgnoreCase(pwd)){ Toast.makeText(SysSettingActivity.this, "输入的密码与原密码不一致", Toast.LENGTH_SHORT).show(); }else if(xpwd.equals("")){ Toast.makeText(SysSettingActivity.this, "请输入新密码", Toast.LENGTH_SHORT).show();
时间: 2024-03-28 18:38:31 浏览: 20
这是一个 Android 开发中的方法,它是在 SysSettingActivity 类中定义的,作用是为修改按钮设置点击事件监听器。当用户点击修改按钮时,该方法会先从编辑框中获取用户输入的原密码、新密码和确认密码。如果原密码为空,该方法会弹出提示框提示用户需要输入原密码;如果原密码与当前保存的密码不一致,该方法会提示用户输入的密码与原密码不一致;如果新密码为空,该方法会提示用户需要输入新密码。其中,Toast.makeText() 方法用于显示一个短时间的提示框,告知用户相应的提示信息。
相关问题
帮我根据以下要求:Then modify the View superclass to: hide the frame when the user clicks on the “close” button; add a “window closing” event handler (use an anonymous window adapter) that calls the controller’s shutdown method.修改下述代码:import javax.swing.JFrame; public abstract class View<T extends Controller> extends JFrame implements ModelListener { protected Model m; protected T c; public View(Model m, T c) { this.m = m; this.c = c; m.addListener(this); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override public abstract void update(); },public class MyFrame extends View<ControllerClicks> { public MyFrame(Model m, ControllerClicks c) { super(m, c); this.setTitle("MyFrame Title"); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setLayout(new BorderLayout()); MyPanel centerPanel = new MyPanel(m, c); this.add(centerPanel, BorderLayout.CENTER); JPanel topPanel = new JPanel(); this.add(topPanel, BorderLayout.PAGE_START); topPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton resetButton = new JButton("Reset"); resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { c.resetClicked(); } }); topPanel.add(resetButton); JButton undoButton = new JButton("Undo"); undoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { c.undoClicked(); } }); topPanel.add(undoButton); this.setVisible(true); } @Override public void update() { repaint(); // Makes Swing call MyPanel's paintComponent method. } } import javax.swing.JLabel; public class ViewNumber extends View<Controller> { private JLabel label; public ViewNumber(Model m, Controller c) { super(m, c); this.setTitle("View Number"); this.setSize(150, 150); label = new JLabel(); update(); // Initialize the label using the model. this.add(label); this.setVisible(true); } @Override public void update() { label.setText("Number of points is: " + m.numberOfPoints()); } }
修改后的代码如下:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public abstract class View<T extends Controller> extends JFrame implements ModelListener {
protected Model m;
protected T c;
public View(Model m, T c) {
this.m = m;
this.c = c;
m.addListener(this);
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
c.shutdown();
}
});
}
@Override
public abstract void update();
}
public class MyFrame extends View<ControllerClicks> {
public MyFrame(Model m, ControllerClicks c) {
super(m, c);
this.setTitle("MyFrame Title");
this.setSize(400, 300);
this.setLocationRelativeTo(null);
this.setLayout(new BorderLayout());
MyPanel centerPanel = new MyPanel(m, c);
this.add(centerPanel, BorderLayout.CENTER);
JPanel topPanel = new JPanel();
this.add(topPanel, BorderLayout.PAGE_START);
topPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton resetButton = new JButton("Reset");
resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
c.resetClicked();
}
});
topPanel.add(resetButton);
JButton undoButton = new JButton("Undo");
undoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
c.undoClicked();
}
});
topPanel.add(undoButton);
this.setVisible(true);
}
@Override
public void update() {
repaint(); // Makes Swing call MyPanel's paintComponent method.
}
}
import javax.swing.JLabel;
public class ViewNumber extends View<Controller> {
private JLabel label;
public ViewNumber(Model m, Controller c) {
super(m, c);
this.setTitle("View Number");
this.setSize(150, 150);
label = new JLabel();
update(); // Initialize the label using the model.
this.add(label);
this.setVisible(true);
}
@Override
public void update() {
label.setText("Number of points is: " + m.numberOfPoints());
}
}
解释代码的含义和作用 para_profile.param_rofile_dir="/customer/conf_backup"; para_profile.isp_caller = product_modify_sc_fun; para_profile.misc_page_caller = para_misc_modify_fun; para_profile.netport_caller = para_netport_modify_fun; para_profile.af_caller = para_af_modify_fun; register_para_sc_config();
这段代码的作用是注册一个参数配置,其中包括了参数配置文件的路径、各个参数修改函数的指针等信息。具体来说,para_profile.param_rofile_dir="/customer/conf_backup" 表示参数配置文件的路径为 "/customer/conf_backup";para_profile.isp_caller = product_modify_sc_fun; 表示 ISP 参数修改函数的指针为 product_modify_sc_fun;para_profile.misc_page_caller = para_misc_modify_fun; 表示杂项页面参数修改函数的指针为 para_misc_modify_fun;para_profile.netport_caller = para_netport_modify_fun; 表示网络端口参数修改函数的指针为 para_netport_modify_fun;para_profile.af_caller = para_af_modify_fun; 表示 AF 参数修改函数的指针为 para_af_modify_fun。最后,register_para_sc_config() 函数用于注册这个参数配置。