实现点击按钮跳转页面功能,当点击登录时 会根据输入的用户名 密码 是否跳转页面
private Button myButtonlogin; private EditText metUser; private EditText metPassword; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myButtonlogin=findViewById(R.id.et4); metUser=findViewById(R.id.et2); metPassword=findViewById(R.id.et3); myButtonlogin.setOnClickListener(this); } public void onClick(View view) { String ok="登录成功"; String fail="密码或账号有误"; String username=metUser.getText().toString(); String password=metPassword.getText().toString(); Intent intent=null; if(username.equals("20223709")&&password.equals("123456")) { ToastUtil.showMsg(MainActivity.this,ok); intent = new Intent(MainActivity.this, SlideActivity.class); startActivity(intent); } else { ToastUtil.showMsg(MainActivity.this,fail); } }
标签:myButtonlogin,metPassword,String,安卓,程序开发,private,id,MainActivity,二十四日 From: https://www.cnblogs.com/youxiandechilun/p/18040589