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打開(kāi)和保存對(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中協(xié)調(diào)滾動(dòng)布局的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android中協(xié)調(diào)滾動(dòng)常用的布局實(shí)現(xiàn),類似這樣的協(xié)調(diào)滾動(dòng)布局,當(dāng)?shù)撞苛斜砘瑒?dòng)的時(shí)候,頂部的布局做響應(yīng)的動(dòng)作,我們都可以通過(guò)?AppBarLayout?和?MotionLayout?來(lái)實(shí)現(xiàn),本文通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友參考下吧2022-06-06
Android中創(chuàng)建快捷方式代碼實(shí)例
這篇文章主要介紹了Android中創(chuàng)建快捷方式代碼實(shí)例,本文分為三個(gè)步驟實(shí)現(xiàn),并分別給出對(duì)應(yīng)實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-04-04
Android自定義View實(shí)現(xiàn)彈性小球效果
前段時(shí)間看到一個(gè)功能,是一個(gè)小球沿著固定軌跡彈動(dòng)的效果,那么這篇文章小編給大家分享在Android中如何自定義View來(lái)實(shí)現(xiàn)彈性小球的效果,有需要的可以參考借鑒。2016-09-09
解決android.support.v4.content.FileProvide找不到的問(wèn)題
這篇文章主要介紹了解決android.support.v4.content.FileProvide找不到的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
Android開(kāi)發(fā)實(shí)現(xiàn)的圖片瀏覽功能示例【放大圖片】
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)的圖片瀏覽功能,結(jié)合實(shí)例形式分析了Android針對(duì)圖片的切換顯示、透明度、大小調(diào)整等相關(guān)操作技巧,需要的朋友可以參考下2019-04-04
Android加載大分辨率圖片到手機(jī)內(nèi)存中的實(shí)例方法
有些圖片的分辨率比較高,把它直接加載到手機(jī)內(nèi)存中之后,會(huì)導(dǎo)致堆內(nèi)存溢出的問(wèn)題,下面就講解一下Android的堆內(nèi)存以及如何在Android應(yīng)用中加載一個(gè)高分辨率的圖片的方法2013-11-11
基于Android AIDL進(jìn)程間通信接口使用介紹
本篇文章小編為大家介紹,基于Android AIDL進(jìn)程間通信接口使用介紹。需要的朋友參考下2013-04-04

