Skip to content

Commit

Permalink
增加清除字符串
Browse files Browse the repository at this point in the history
  • Loading branch information
mosentest committed Mar 5, 2019
1 parent cfdff9b commit 30f7891
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Step 2. Add the dependency
</declare-styleable>
</resources>
<com.moziqi.pwd.widget.VerificationCodeView
android:id="@+id/verificationcodeview"
android:layout_width="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.1'
// compile project(":pswkeyboardlibrary")
compile project(":pswkeyboardlibrary")
// compile 'com.jyn.verificationcodeview:verificationcodeview:1.0.0'
compile 'com.github.moz1q1:WeChatPswKeyboard:1.0.7'
// compile 'com.github.moz1q1:WeChatPswKeyboard:1.0.7'
}
16 changes: 16 additions & 0 deletions app/src/main/java/com/lnyp/pswkeyboard/MsgActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.moziqi.pwd.widget.VerificationCodeView;

public class MsgActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_msg);
final VerificationCodeView verificationCodeView = findViewById(R.id.verificationcodeview);
verificationCodeView.setOnCodeFinishListener(new VerificationCodeView.OnCodeFinishListener() {
@Override
public void onComplete(String content) {

}
});
findViewById(R.id.tv_reset).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
verificationCodeView.clearText();
}
});
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_msg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@
app:vcv_et_number="6"
app:vcv_et_text_color="@android:color/black"
app:vcv_et_text_size="14sp" />

<TextView
android:id="@+id/tv_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="重置" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ private void getResult() {
}
}

public void clearText() {
EditText editText;
for (int i = 0; i < mEtNumber; i++) {
editText = (EditText) getChildAt(i);
editText.setText("");
}
focus();
}

@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
Expand Down

0 comments on commit 30f7891

Please sign in to comment.