首先添加上图按钮的监听事件代码
Java代码
-
-
-
- private void showSetPsdDialog() {
-
- Builder builder = new Builder(this);
- final AlertDialog dialog = builder.create();
- final View view = inflate(this, R.layout.dialog_set_psd, null);
-
- dialog.setView(view);
- dialog.show();
-
- Button bt_submit = (Button) view.findViewById(R.id.bt_submit);
- Button bt_cancel = (Button) view.findViewById(R.id.bt_cancel);
-
- bt_submit.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- EditText et_set_psd = (EditText) view.findViewById(R.id.et_set_psd);
- EditText et_confirm_psd = (EditText) view.findViewById(R.id.et_confirm_psd);
- String psd = et_set_psd.getText().toString();
- String confirmPsd = et_confirm_psd.getText().toString();
- if(!TextUtils.isEmpty(psd) && !TextUtils.isEmpty(confirmPsd)){
-
- if(psd.equals(confirmPsd)) {
- Intent intent = new Intent(getApplicationContext(), testActivity.class);
- startActivity(intent);
-
- dialog.dismiss();
- } else {
- ToastUtil.show(getApplicationContext(),"密码不一致");
- }
-
- }else{
-
- ToastUtil.show(getApplicationContext(),"请输入密码");
- }
- }
- });
- bt_cancel.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- dialog.dismiss();
- }
- });
- }
这里新建一个activity:testActivity用来测试,先看到效果,具体后面再实现
Java代码
- public class testActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- TextView textView = new TextView(this);
- textView.setText("testActivity!");
-
- setContentView(textView);
- }
- }
然后在清单文件中添加下面的代码:
XML/HTML代码
- <activity android:name="com.wuyudong.mobilesafe.activity.testActivity"></activity>