最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)支付寶支付密碼輸入界面

 更新時(shí)間:2022年05月19日 17:10:15   作者:成都-idea  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)支付寶支付密碼輸入界面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)支付寶支付密碼輸入界面的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

主要代碼:

import java.util.ArrayList;
?
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
?
import com.example.payui.KeyboardEnum.ActionEnum;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.lidroid.xutils.view.annotation.event.OnLongClick;
/**
?* Dialog 顯示視圖
?* @author LanYan
?*
?*/
@SuppressLint("InflateParams")
public class PayPasswordView{
?
?? ?@ViewInject(R.id.pay_keyboard_del)
?? ?private ImageView del;
?? ?@ViewInject(R.id.pay_keyboard_zero)
?? ?private ImageView zero;
?? ?@ViewInject(R.id.pay_keyboard_one)
?? ?private ImageView one;
?? ?@ViewInject(R.id.pay_keyboard_two)
?? ?private ImageView two;
?? ?@ViewInject(R.id.pay_keyboard_three)
?? ?private ImageView three;
?? ?@ViewInject(R.id.pay_keyboard_four)
?? ?private ImageView four;
?? ?@ViewInject(R.id.pay_keyboard_five)
?? ?private ImageView five;
?? ?@ViewInject(R.id.pay_keyboard_sex)
?? ?private ImageView sex;
?? ?@ViewInject(R.id.pay_keyboard_seven)
?? ?private ImageView seven;
?? ?@ViewInject(R.id.pay_keyboard_eight)
?? ?private ImageView eight;
?? ?@ViewInject(R.id.pay_keyboard_nine)
?? ?private ImageView nine;
?? ?@ViewInject(R.id.pay_cancel)
?? ?private TextView cancel;
?? ?@ViewInject(R.id.pay_sure)
?? ?private TextView sure;
?? ?@ViewInject(R.id.pay_box1)
?? ?private TextView box1;
?? ?@ViewInject(R.id.pay_box2)
?? ?private TextView box2;
?? ?@ViewInject(R.id.pay_box3)
?? ?private TextView box3;
?? ?@ViewInject(R.id.pay_box4)
?? ?private TextView box4;
?? ?@ViewInject(R.id.pay_box5)
?? ?private TextView box5;
?? ?@ViewInject(R.id.pay_box6)
?? ?private TextView box6;
?? ?@ViewInject(R.id.pay_title)
?? ?private TextView title;
?? ?@ViewInject(R.id.pay_content)
?? ?private TextView content;
?? ?
?? ?private ArrayList<String> mList=new ArrayList<String>();
?? ?private View mView;
?? ?private OnPayListener listener;
?? ?private Context mContext;
?? ?public PayPasswordView(){
?? ??? ?
?? ?}
?? ?public static PayPasswordView getInstance(){
?? ??? ?return ?new PayPasswordView();
?? ?}
?? ?
?? ?public View getDecorView(String monney,Context mContext,OnPayListener listener){
?? ??? ?this.listener=listener;
?? ??? ?this.mContext=mContext;
?? ??? ?mView=LayoutInflater.from(mContext).inflate(R.layout.item_paypassword, null);
?? ??? ?ViewUtils.inject(this,mView);
?? ??? ?content.setText("消費(fèi)金額:"+monney+"元");
?? ??? ?return mView;
?? ?}
?? ?
?? ?@OnClick({R.id.pay_keyboard_del,R.id.pay_keyboard_zero,
?? ??? ?R.id.pay_keyboard_one,R.id.pay_keyboard_two,
?? ??? ?R.id.pay_keyboard_three,R.id.pay_keyboard_four,
?? ??? ?R.id.pay_keyboard_five,R.id.pay_keyboard_sex,
?? ??? ?R.id.pay_keyboard_seven,R.id.pay_keyboard_eight,
?? ??? ?R.id.pay_keyboard_nine,R.id.pay_cancel,
?? ??? ?R.id.pay_sure})
?? ?private void onClick(View v){
?? ??? ?if(v==zero){
?? ??? ??? ?parseActionType(KeyboardEnum.zero);
?? ??? ?}else if(v==one){
?? ??? ??? ?parseActionType(KeyboardEnum.one);
?? ??? ?}else if(v==two){
?? ??? ??? ?parseActionType(KeyboardEnum.two);
?? ??? ?}else if(v==three){
?? ??? ??? ?parseActionType(KeyboardEnum.three);
?? ??? ?}else if(v==four){
?? ??? ??? ?parseActionType(KeyboardEnum.four);
?? ??? ?}else if(v==five){
?? ??? ??? ?parseActionType(KeyboardEnum.five);
?? ??? ?}else if(v==sex){
?? ??? ??? ?parseActionType(KeyboardEnum.sex);
?? ??? ?}else if(v==seven){
?? ??? ??? ?parseActionType(KeyboardEnum.seven);
?? ??? ?}else if(v==eight){
?? ??? ??? ?parseActionType(KeyboardEnum.eight);
?? ??? ?}else if(v==nine){
?? ??? ??? ?parseActionType(KeyboardEnum.nine);
?? ??? ?}else if(v==cancel){
?? ??? ??? ?parseActionType(KeyboardEnum.cancel);
?? ??? ?}else if(v==sure){
?? ??? ??? ?parseActionType(KeyboardEnum.sure);
?? ??? ?}else if(v==del){
?? ??? ??? ?parseActionType(KeyboardEnum.del);
?? ??? ?}
?? ?}
?? ?
?? ?@OnLongClick(R.id.pay_keyboard_del)
?? ?public boolean onLongClick(View v) {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?parseActionType(KeyboardEnum.longdel);
?? ??? ?return false;
?? ?}
?? ?
?? ?private void parseActionType(KeyboardEnum type) {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?if(type.getType()==ActionEnum.add){
?? ??? ??? ?if(mList.size()<6){
?? ??? ??? ??? ?mList.add(type.getValue());
?? ??? ??? ??? ?updateUi();
?? ??? ??? ?}
?? ??? ?}else if(type.getType()==ActionEnum.delete){
?? ??? ??? ?if(mList.size()>0){
?? ??? ??? ??? ?mList.remove(mList.get(mList.size()-1));
?? ??? ??? ??? ?updateUi();
?? ??? ??? ?}
?? ??? ?}else if(type.getType()==ActionEnum.cancel){
?? ??? ??? ?listener.onCancelPay();
?? ??? ?}else if(type.getType()==ActionEnum.sure){
?? ??? ??? ?if(mList.size()<6){
?? ??? ??? ??? ?Toast.makeText(mContext, "支付密碼必須6位", Toast.LENGTH_SHORT).show();
?? ??? ??? ?}else{
?? ??? ??? ??? ?String payValue="";
?? ??? ??? ??? ?for (int i = 0; i < mList.size(); i++) {
?? ??? ??? ??? ??? ?payValue+=mList.get(i);
?? ??? ??? ??? ?}
?? ??? ??? ??? ?listener.onSurePay(payValue);
?? ??? ??? ?}
?? ??? ?}else if(type.getType()==ActionEnum.longClick){
?? ??? ??? ?mList.clear();
?? ??? ??? ?updateUi();
?? ??? ?}
?? ??? ?
?? ?}
?? ?private void updateUi() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?if(mList.size()==0){
?? ??? ??? ?box1.setText("");
?? ??? ??? ?box2.setText("");
?? ??? ??? ?box3.setText("");
?? ??? ??? ?box4.setText("");
?? ??? ??? ?box5.setText("");
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==1){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText("");
?? ??? ??? ?box3.setText("");
?? ??? ??? ?box4.setText("");
?? ??? ??? ?box5.setText("");
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==2){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText(mList.get(1));
?? ??? ??? ?box3.setText("");
?? ??? ??? ?box4.setText("");
?? ??? ??? ?box5.setText("");
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==3){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText(mList.get(1));
?? ??? ??? ?box3.setText(mList.get(2));
?? ??? ??? ?box4.setText("");
?? ??? ??? ?box5.setText("");
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==4){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText(mList.get(1));
?? ??? ??? ?box3.setText(mList.get(2));
?? ??? ??? ?box4.setText(mList.get(3));
?? ??? ??? ?box5.setText("");
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==5){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText(mList.get(1));
?? ??? ??? ?box3.setText(mList.get(2));
?? ??? ??? ?box4.setText(mList.get(3));
?? ??? ??? ?box5.setText(mList.get(4));
?? ??? ??? ?box6.setText("");
?? ??? ?}else if(mList.size()==6){
?? ??? ??? ?box1.setText(mList.get(0));
?? ??? ??? ?box2.setText(mList.get(1));
?? ??? ??? ?box3.setText(mList.get(2));
?? ??? ??? ?box4.setText(mList.get(3));
?? ??? ??? ?box5.setText(mList.get(4));
?? ??? ??? ?box6.setText(mList.get(5));
?? ??? ?}
?? ?}
?? ?
?? ?public interface OnPayListener{
?? ??? ?void onCancelPay();
?? ??? ?void onSurePay(String password);
?? ?}
?? ?
}

Enum:

public enum KeyboardEnum {
?? ?one(ActionEnum.add,"1"),
?? ?two(ActionEnum.add,"2"),
?? ?three(ActionEnum.add,"3"),
?? ?four(ActionEnum.add,"4"),
?? ?five(ActionEnum.add,"5"),
?? ?sex(ActionEnum.add,"6"),
?? ?seven(ActionEnum.add,"7"),
?? ?eight(ActionEnum.add,"8"),
?? ?nine(ActionEnum.add,"9"),
?? ?zero(ActionEnum.add,"0"),
?? ?del(ActionEnum.delete,"del"),
?? ?longdel(ActionEnum.longClick,"longclick"),
?? ?cancel(ActionEnum.cancel,"cancel"),
?? ?sure(ActionEnum.sure,"sure");
?? ?public enum ActionEnum{
?? ??? ?add,delete,longClick,cancel,sure
?? ?}
?? ?private ActionEnum type;
?? ?private String value;
?? ?private KeyboardEnum(ActionEnum type,String value){
?? ??? ?this.type=type;
?? ??? ?this.value=value;
?? ?}
?? ?public ActionEnum getType() {
?? ??? ?return type;
?? ?}
?? ?public void setType(ActionEnum type) {
?? ??? ?this.type = type;
?? ?}
?? ?public String getValue() {
?? ??? ?return value;
?? ?}
?? ?public void setValue(String value) {
?? ??? ?this.value = value;
?? ?}
?
}

測(cè)試類:

public class MainActivity extends Activity {
?
?? ?private DialogWidget mDialogWidget;
?? ?private TextView payTextView;
?
?? ?@Override
?? ?protected void onCreate(Bundle savedInstanceState) {
?? ??? ?super.onCreate(savedInstanceState);
?? ??? ?setContentView(R.layout.activity_main);
?? ??? ?payTextView=(TextView)findViewById(R.id.payEditText);
?? ??? ?payTextView.setOnClickListener(new OnClickListener() {
?? ??? ??? ?
?
?? ??? ??? ?@Override
?? ??? ??? ?public void onClick(View v) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?mDialogWidget=new DialogWidget(MainActivity.this, getDecorViewDialog());
?? ??? ??? ??? ?mDialogWidget.show();
?? ??? ??? ?}
?? ??? ?});
?? ?}
?? ?
?? ?protected View getDecorViewDialog() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?return PayPasswordView.getInstance().getDecorView("45.99",this,new OnPayListener() {
?? ??? ??? ?
?? ??? ??? ?@Override
?? ??? ??? ?public void onSurePay(String password) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?mDialogWidget.dismiss();
?? ??? ??? ??? ?mDialogWidget=null;
?? ??? ??? ??? ?payTextView.setText(password);
?? ??? ??? ??? ?Toast.makeText(getApplicationContext(), "交易成功", Toast.LENGTH_SHORT).show();
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?@Override
?? ??? ??? ?public void onCancelPay() {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?mDialogWidget.dismiss();
?? ??? ??? ??? ?mDialogWidget=null;
?? ??? ??? ??? ?Toast.makeText(getApplicationContext(), "交易已取消", Toast.LENGTH_SHORT).show();
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ?});
?? ?}
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android自定義view漸變圓形動(dòng)畫

    Android自定義view漸變圓形動(dòng)畫

    這篇文章主要為大家詳細(xì)介紹了Android自定義view漸變圓形動(dòng)畫,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • Android手勢(shì)ImageView三部曲 第一部

    Android手勢(shì)ImageView三部曲 第一部

    這篇文章主要為大家詳細(xì)介紹了Android手勢(shì)ImageView三部曲的第一部,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Android Studio Gradle 更換阿里云鏡像的方法

    Android Studio Gradle 更換阿里云鏡像的方法

    這篇文章主要介紹了Android Studio Gradle 更換阿里云鏡像的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 淺談Android Activity與Service的交互方式

    淺談Android Activity與Service的交互方式

    下面小編就為大家?guī)硪黄獪\談Android Activity與Service的交互方式。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-09-09
  • 基于Android實(shí)現(xiàn)的文件同步設(shè)計(jì)方案

    基于Android實(shí)現(xiàn)的文件同步設(shè)計(jì)方案

    隨著用戶對(duì)自身數(shù)據(jù)保護(hù)意識(shí)的加強(qiáng),讓用戶自己維護(hù)自己的數(shù)據(jù)也成了獨(dú)立開發(fā)產(chǎn)品時(shí)的一個(gè)賣點(diǎn),若只針對(duì)少量的文件進(jìn)行同步,則實(shí)現(xiàn)起來比較簡(jiǎn)單,當(dāng)針對(duì)一個(gè)多層級(jí)目錄同步時(shí),情況就復(fù)雜多了,本文我分享下我的設(shè)計(jì)思路
    2023-10-10
  • Android 基于IntentService的文件下載的示例代碼

    Android 基于IntentService的文件下載的示例代碼

    本篇文章主要介紹了Android 基于IntentService的文件下載的示例代碼,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-09-09
  • android app跳轉(zhuǎn)應(yīng)用商店實(shí)現(xiàn)步驟

    android app跳轉(zhuǎn)應(yīng)用商店實(shí)現(xiàn)步驟

    這篇文章主要為大家介紹了android app跳轉(zhuǎn)應(yīng)用商店實(shí)現(xiàn)步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • Android 實(shí)現(xiàn)帶頭部文字輸入框的自定義控件

    Android 實(shí)現(xiàn)帶頭部文字輸入框的自定義控件

    這篇文章主要介紹了Android 實(shí)現(xiàn)帶頭部文字輸入框的自定義控件,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下
    2021-04-04
  • Android中協(xié)調(diào)滾動(dòng)布局的實(shí)現(xià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)作,我們都可以通過?AppBarLayout?和?MotionLayout?來實(shí)現(xiàn),本文通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友參考下吧
    2022-06-06
  • Android編程實(shí)現(xiàn)換膚功能實(shí)例

    Android編程實(shí)現(xiàn)換膚功能實(shí)例

    這篇文章主要介紹了Android編程實(shí)現(xiàn)換膚功能的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了Android換膚的具體步驟與相關(guān)技巧,需要的朋友可以參考下
    2015-12-12

最新評(píng)論

万安县| 醴陵市| 防城港市| 富平县| 临泽县| 鄂托克旗| 万山特区| 雷州市| 昭通市| 古田县| 新乡市| 电白县| 章丘市| 新平| 泰顺县| 宁化县| 定安县| 平阴县| 巴青县| 靖宇县| 易门县| 洛南县| 双辽市| 旬阳县| 航空| 苗栗县| 新乡市| 龙州县| 五莲县| 丰城市| 合作市| 凤冈县| 社会| 香港 | 陆川县| 普兰店市| 天长市| 都江堰市| 桦川县| 客服| 盐城市|