【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析_第1頁
【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析_第2頁
【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析_第3頁
【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析_第4頁
【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

【移動應(yīng)用開發(fā)技術(shù)】Android高仿微信支付密碼輸入控件的示例分析

/upload/information/20201208/260/10677.jpgfor

(int

i

=

0;

i

<

6;

i++)

{

TextView

textView

=

new

TextView(context);

android.widget.LinearLayout.LayoutParams

layoutParams

=

new

android.widget.LinearLayout.LayoutParams(

0,

android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,

1);

textView.setGravity(Gravity.CENTER);

textView.setTransformationMethod(PasswordTransformationMethod.getInstance());

textView.setTextSize(32);

textView.setLayoutParams(layoutParams);

ll_pwd.addView(textView);

if

(i

!=

5)

{

View

view2

=

new

View(context);

android.widget.LinearLayout.LayoutParams

layoutParams1

=

new

android.widget.LinearLayout.LayoutParams(

1,

android.widget.LinearLayout.LayoutParams.MATCH_PARENT,

0);

view2.setLayoutParams(layoutParams1);

view2.setBackgroundColor(Color.parseColor("#999999"));

ll_pwd.addView(view2);

}

tvList[i]

=

textView;

}/upload/information/20201208/260/10678.jpg

/**

*

加載數(shù)據(jù)的代碼

*/

private

void

initData()

{

/*

初始化按鈕上應(yīng)該顯示的數(shù)字

*/

for

(int

i

=

1;

i

<

13;

i++)

{

Map<String,

String>

map

=

new

HashMap<String,

String>();

if

(i

<

10)

{

map.put("name",

String.valueOf(i));

}

else

if

(i

==

10)

{

map.put("name",

"");

}

else

if

(i

==

11)

{

map.put("name",

String.valueOf(0));

}

else

if

(i

==

12)

{

map.put("name",

"×");

}

else

{

map.put("name",

"");

}

valueList.add(map);

}

gridView.setAdapter(adapter);

gridView.setOnItemClickListener(new

AdapterView.OnItemClickListener()

{

@Override

public

void

onItemClick(AdapterView<?>

parent,

View

view,

int

position,

long

id)

{

if

(position

<

11

&&

position

!=

9)

{

//

點擊0~9按鈕

if

(currentIndex

>=

-1

&&

currentIndex

<

5)

{

//

判斷輸入位置————要小心數(shù)組越界

tvList[++currentIndex].setText(valueList.get(position)

.get("name"));

}

}

else

{

if

(position

==

11)

{

//

點擊退格鍵

if

(currentIndex

-

1

>=

-1)

{

//

判斷是否刪除完畢————要小心數(shù)組越界

tvList[currentIndex--].setText("");

}

}

}

}

});

}

/**

*

GrideView的適配器

*/

BaseAdapter

adapter

=

new

BaseAdapter()

{

@Override

public

int

getCount()

{

return

valueList.size();

}

@Override

public

Object

getItem(int

position)

{

return

valueList.get(position);

}

@Override

public

long

getItemId(int

position)

{

return

position;

}

@SuppressWarnings("deprecation")

@Override

public

View

getView(int

position,

View

convertView,

ViewGroup

parent)

{

ViewHolder

viewHolder;

if

(convertView

==

null)

{

convertView

=

View.inflate(context,

R.layout.item_gride,

null);

viewHolder

=

new

ViewHolder();

viewHolder.btnKey

=

(TextView)

convertView

.findViewById(R.id.btn_keys);

convertView.setTag(viewHolder);

}

else

{

viewHolder

=

(ViewHolder)

convertView.getTag();

}

viewHolder.btnKey.setText(valueList.get(position).get("name"));

if

(position

==

9||position==11)

{

viewHolder.btnKey.setBackgroundDrawable(Utils.getStateListDrawable(context));

viewHolder.btnKey.setEnabled(false);

}

if

(position

==

11)

{

viewHolder.btnKey.setBackgroundDrawable(Utils.getStateListDrawable(context));

}

return

convertView;

}

};

/**

*

存放控件

*/

public

final

class

ViewHolder

{

public

TextView

btnKey;

}View

contentView

=

LayoutInflater.from(context).inflate(

R.layout.layout_popupdemo,

null);//

定義后退彈出框

gridView

=

(GridView)

contentView.findViewById(R.id.gv_keybord);//

泡泡窗口的布局

popupWindow

=

new

PopupWindow(contentView,

ViewGroup.LayoutParams.MATCH_PARENT,//

width

ViewGroup.LayoutParams.WRAP_CONTENT);//

higth

popupWindow.setFocusable(false);

popupWindow.setAnimationStyle(R.style.animation);

//從底部彈出

public

void

show()

{

popupWindow.showAtLocation(rl_bottom,

Gravity.BOTTOM,

0,

0);

//

確定在界面中出現(xiàn)的位置

}

@Override

public

void

onWindowFocusChanged(boolean

hasWindowFocus)

{

super.onWindowFocusChanged(hasWindowFocus);

show();

}gridView.setOnItemClickListener(new

AdapterView.OnItemClickListener()

{

@Override

public

void

onItemClick(AdapterView<?>

parent,

View

view,

int

position,

long

id)

{

if

(position

<

11

&&

position

!=

9)

{

//

點擊0~9按鈕

if

(currentIndex

>=

-1

&&

currentIndex

<

5)

{

//

判斷輸入位置————要小心數(shù)組越界

tvList[++currentIndex].setText(valueList.get(position)

.get("name"));

}

}

else

{

if

(position

==

11)

{

//

點擊退格鍵

if

(currentIndex

-

1

>=

-1)

{

//

判斷是否刪除完畢————要小心數(shù)組越界

tvList[currentIndex--].setText("");

}

}

}

}

});//

設(shè)置監(jiān)聽方法,在第6位輸入完成后觸發(fā)

public

void

setOnFinishInput(final

OnPasswordInputFinish

pass)

{

tvList[5].addTextChangedListener(new

TextWatcher()

{

@Override

public

void

beforeTextChanged(CharSequence

s,

int

start,

int

count,

int

after)

{

}

@Override

public

void

onTextChanged(CharSequence

s,

int

start,

int

before,

int

count)

{

}

@Override

public

void

afterTextChanged(Editable

s)

{

if

(s.toString().length()

==

1)

{

strPassword

=

"";

//

每次觸發(fā)都要先將strPassword置空,再重新獲取,避

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論