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