Android手機衛(wèi)士之確認密碼對話框
本文接著實現(xiàn)“確認密碼”功能,也即是用戶以前設(shè)置過密碼,現(xiàn)在只需要輸入確認密碼
布局文件和《Android 手機衛(wèi)士--設(shè)置密碼對話框》中的布局基本類似,所有copy一下,修改一點細節(jié)就搞定:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView style="@style/TitleStyle" android:background="#f00" android:text="確認密碼" /> <EditText android:id="@+id/et_confirm_psd" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="確認密碼" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/bt_submit" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="確認" /> <Button android:id="@+id/bt_cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="取消" /> </LinearLayout> </LinearLayout>
代碼邏輯也基本類似,簡單的修改一下
/** * 確認密碼對話框 */ private void showConfirmPsdDialog() { //需要自己去定義對話框的顯示樣式,所以要調(diào)用dialog.setView(view); Builder builder = new Builder(this); final AlertDialog dialog = builder.create(); final View view = inflate(this, R.layout.dialog_confirm_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_confirm_psd = (EditText) view.findViewById(R.id.et_confirm_psd); String confirmPsd = et_confirm_psd.getText().toString(); String psd = SpUtil.getString(getApplicationContext(),ConstantValue.MOBILE_SAFE_PSD, ""); if(!TextUtils.isEmpty(confirmPsd)){ //進入用戶手機防盜模塊 if(psd.equals(confirmPsd)) { Intent intent = new Intent(getApplicationContext(), testActivity.class); startActivity(intent); //跳轉(zhuǎn)到新的界面以后需要去隱藏對話框 dialog.dismiss(); } else { ToastUtil.show(getApplicationContext(),"輸入密碼錯誤"); } }else{ //提示用戶密碼輸入為空的情況 ToastUtil.show(getApplicationContext(),"請輸入密碼"); } } }); bt_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android對話框自定義標(biāo)題 對話框標(biāo)題美化操作
- 懸浮對話框Android代碼實現(xiàn)
- 非常簡單的Android打開和保存對話框功能
- Android UI設(shè)計系列之自定義Dialog實現(xiàn)各種風(fēng)格的對話框效果(7)
- Android AlertDialog實現(xiàn)分享對話框/退出對話框/下載對話框
- 8種android 對話框(Dialog)使用方法詳解
- Android自定義等待對話框
- 屬于自己的Android對話框(Dialog)自定義集合
- 簡析Android多種AlertDialog對話框效果
- Android中自定義對話框(Dialog)的實例代碼
相關(guān)文章
Android中l(wèi)istview和imageview實現(xiàn)條目單選效果
這篇文章主要為大家詳細介紹了Android中l(wèi)istview和imageview實現(xiàn)條目單選效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-02-02ActivityManagerService廣播并行發(fā)送與串行發(fā)送示例解析
這篇文章主要為大家介紹了ActivityManagerService廣播并行發(fā)送與串行發(fā)送示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-03-03Android實現(xiàn)濾鏡效果ColorMatrix
這篇文章主要為大家詳細介紹了Android實現(xiàn)濾鏡效果ColorMatrix,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-05-05Android中Retrofit+OkHttp進行HTTP網(wǎng)絡(luò)編程的使用指南
Retrofit和OkHttp都是Square在GitHub上開源的第三方HTTP支持包,兩個包可以搭配使用,本文即是來講解Android中Retrofit+OkHttp進行HTTP網(wǎng)絡(luò)編程的使用指南:2016-07-07