标签:ica err text cli find esc his touch hal
先上图看看实现效果
implementation ‘com.luozm.captcha:captcha:1.1.2‘
<com.luozm.captcha.Captcha android:id="@+id/captCha" android:layout_centerInParent="true" android:layout_width="match_parent" android:layout_height="265dp" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" app:mode="mode_bar" app:src="@drawable/validate" app:blockSize="50dp" android:scaleType="centerCrop" app:max_fail_count="4"/>
public void showw(String advPic) { Context context = MainActivity.this; diaa = new Dialog(context, R.style.edit_AlertDialog_style); diaa.setContentView(R.layout.item_pict); captcha = diaa.findViewById(R.id.captCha); final Button btn_mode = diaa.findViewById(R.id.btn_mode); final Captcha captcha = diaa.findViewById(R.id.captCha); ImageView cuowu = diaa.findViewById(R.id.im_cuowu); // Glide.with(getApplication()).load(advPic).into(captcha ); captcha.setBitmap(advPic); btn_mode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (captcha.getMode() == Captcha.MODE_BAR) { captcha.setMode(Captcha.MODE_NONBAR); btn_mode.setText("滑动条模式"); } else { captcha.setMode(Captcha.MODE_BAR); btn_mode.setText("无滑动条模式"); } } }); cuowu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diaa.dismiss(); itData(mLongitude, mLatitude); } }); captcha.setCaptchaListener(new Captcha.CaptchaListener() { @Override public String onAccess(long time) { Toast.makeText(MainActivity.this, "验证成功", Toast.LENGTH_SHORT).show(); diaa.dismiss(); diaa.setCanceledOnTouchOutside(true); return "验证通过"; } @Override public String onFailed(int count) { Toast.makeText(MainActivity.this, "验证失败,失败次数" + count, Toast.LENGTH_SHORT).show(); return "验证失败"; } @Override public String onMaxFailed() { Toast.makeText(MainActivity.this, "验证超过次数,你的帐号被封锁", Toast.LENGTH_SHORT).show(); return "可以走了"; } }); diaa.show(); diaa.setCanceledOnTouchOutside(true); Window w = diaa.getWindow(); WindowManager.LayoutParams lp = w.getAttributes(); lp.x = 0; lp.y = 40; diaa.onWindowAttributesChanged(lp); }
标签:ica err text cli find esc his touch hal
原文地址:https://www.cnblogs.com/monkey0928/p/9864094.html