亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android 自定義對話框 showSetPwdDialog

 更新時間:2016年03月29日 09:13:50   作者:榮雪---rongsnow  
這篇文章主要介紹了Android 自定義對話框 showSetPwdDialog的相關(guān)資料,需要的朋友可以參考下

樣式如下所示:

布局:

layout

  dialog_set_pwd.xml

<?xml version="." encoding="utf-"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#EFEFEF"
android:orientation="horizontal"
android:padding="dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dialog_title_default_icon" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="dp"
android:text="設(shè)置密碼"
android:textColor="@color/black"
android:textSize="sp" />
</LinearLayout>
<EditText
android:id="@+id/et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="dp"
android:hint="請輸入密碼"
android:inputType="textPassword" >
</EditText>
<EditText
android:id="@+id/et_pwd_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="dp"
android:hint="請再次輸入密碼"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="dp" >
<Button
android:id="@+id/btn_ok"
android:layout_width="dp"
android:layout_height="wrap_content"
android:layout_weight=""
android:background="@drawable/btn_blue_selector"
android:text="確定"
android:layout_marginRight="dp"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="dp"
android:layout_height="wrap_content"
android:layout_weight=""
android:background="@drawable/btn_white_selector"
android:text="取消"
android:textColor="@color/black" />
</LinearLayout>
</LinearLayout>

狀態(tài)選擇器:

drawable

  btn_blue_selector.xml

<?xml version="." encoding="utf-"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dg_btn_confirm_select" android:state_pressed="true"></item>
<item android:drawable="@drawable/dg_btn_confirm_normal"></item>
</selector>

  btn_white_selector.xml

<?xml version="." encoding="utf-"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dg_button_cancel_select" android:state_pressed="true"></item>
<item android:drawable="@drawable/dg_button_cancel_normal"></item>
</selector>

引用值

values

  colors.xml

<?xml version="." encoding="utf-"?>
<resources>
<color name="black">#</color>
<color name="gray">#a</color>
<color name="white">#fff</color>
<color name="red">#f</color>
<color name="shape_setting_normal">#BDEE</color>
<color name="shape_setting_pressed">#CAD</color>
<color name="blue">#FD</color>
<color name="light_green">#f</color>
</resources> 

代碼:

private void showSetPwdDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = View.inflate(this, R.layout.dialog_set_pwd, null);
Button btnOk = (Button) view.findViewById(R.id.btn_ok);
Button btnCancel = (Button) view.findViewById(R.id.btn_cancel);
final EditText etPwd = (EditText) view.findViewById(R.id.et_pwd);
final EditText etPwdConfirm = (EditText) view
.findViewById(R.id.et_pwd_confirm);
builder.setView(view);//將當(dāng)前布局對象設(shè)置給dialog
final AlertDialog dialog = builder.create();
btnOk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String pwd = etPwd.getText().toString().trim();
String pwdConfirm = etPwdConfirm.getText().toString().trim();
if (TextUtils.isEmpty(pwd) || TextUtils.isEmpty(pwdConfirm)) {
ToastUtils.showToast(getApplicationContext(), "輸入內(nèi)容不能為空!");
} else {
if (pwd.equals(pwdConfirm)) {
System.out.println("登錄成功!");
//將密碼保存在本地sp
PrefUtils.putString(getApplicationContext(),
GlobalConstants.PREF_PASSWORD,
MDUtils.getMd(pwd));
dialog.dismiss();
enterLostAndFindPage();
} else {
ToastUtils.showToast(getApplicationContext(),
"兩次密碼不一致!");
}
}
}
});
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}

有關(guān)Android 自定義對話框 showSetPwdDialog,小編就給大家介紹這么多,希望對大家有所幫助!

相關(guān)文章

  • Android自定義View實現(xiàn)心形圖案

    Android自定義View實現(xiàn)心形圖案

    這篇文章主要為大家詳細(xì)介紹了Android自定義View實現(xiàn)心形圖案,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Android提高之模擬信號示波器的實現(xiàn)

    Android提高之模擬信號示波器的實現(xiàn)

    這篇文章主要介紹了Android模擬信號示波器的實現(xiàn)方法,在Android項目開發(fā)中有一定的實用價值,需要的朋友可以參考下
    2014-08-08
  • Flutter實現(xiàn)仿京東商品詳情底部操作欄

    Flutter實現(xiàn)仿京東商品詳情底部操作欄

    這篇文章主要為大家詳細(xì)介紹了Flutter如何仿京東實現(xiàn)商品詳情底部操作欄,文中的示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價值,感興趣的小伙伴可以了解一下
    2023-06-06
  • Android 軟鍵盤自動彈出與關(guān)閉實例詳解

    Android 軟鍵盤自動彈出與關(guān)閉實例詳解

    這篇文章主要介紹了Android 軟鍵盤自動彈出與關(guān)閉實例詳解的相關(guān)資料,為了用戶體驗應(yīng)該自動彈出軟鍵盤而不是讓用戶主動點擊輸入框才彈出,這里舉例說明該如何實現(xiàn),需要的朋友可以參考下
    2016-12-12
  • Android 使用幀動畫內(nèi)存溢出解決方案

    Android 使用幀動畫內(nèi)存溢出解決方案

    這篇文章主要介紹了Android 使用幀動畫內(nèi)存溢出解決方案的相關(guān)資料,這里提供了詳細(xì)的解決辦法,具有參考價值,需要的朋友可以參考下
    2016-12-12
  • Android實現(xiàn)動態(tài)自動匹配輸入內(nèi)容功能

    Android實現(xiàn)動態(tài)自動匹配輸入內(nèi)容功能

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)動態(tài)自動匹配輸入內(nèi)容功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 淺談Glide緩存key的問題

    淺談Glide緩存key的問題

    這篇文章主要介紹了淺談Glide緩存key的問題,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-04-04
  • Android開發(fā)之Location用法實例分析

    Android開發(fā)之Location用法實例分析

    這篇文章主要介紹了Android開發(fā)中Location用法,結(jié)合實例形式分析了Android使用location控件獲取經(jīng)緯度信息的相關(guān)操作技巧,需要的朋友可以參考下
    2016-10-10
  • android 監(jiān)聽SD卡文件變化的實現(xiàn)代碼

    android 監(jiān)聽SD卡文件變化的實現(xiàn)代碼

    這篇文章主要介紹了android 監(jiān)聽SD卡文件變化的實現(xiàn)代碼,需要的朋友可以參考下
    2017-11-11
  • Android編程實現(xiàn)隨機生成顏色的方法示例

    Android編程實現(xiàn)隨機生成顏色的方法示例

    這篇文章主要介紹了Android編程實現(xiàn)隨機生成顏色的方法,結(jié)合實例形式分析了Android使用java Random類針對隨機數(shù)及顏色值相關(guān)操作技巧,需要的朋友可以參考下
    2017-08-08

最新評論