我正在开发一个带有图案锁定的 Android 应用程序,我希望图案锁定显示数字而不是点。这怎么可能?下面是源代码。图案锁工作正常。但我想显示数字而不是点。
MainActivity.java
public class MainActivity extends ActionBarActivity {
private PatternView patternView;
private String patternString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
patternView = (PatternView) findViewById(R.id.patternView);
patternView.setTactileFeedbackEnabled(false);
Toast.makeText(getApplicationContext(), "ENTER PATTERN", Toast.LENGTH_LONG).show();
patternView.setPathColor(Color.BLACK);
patternView.setDotColor(Color.BLACK);
patternView.setCircleColor(Color.BLACK);
patternView.setOnPatternDetectedListener(new PatternView.OnPatternDetectedListener() {
@Override
public void onPatternDetected() {
if (patternString == null) {
patternString = patternView.getPatternString();
return;
}
if (patternString.equals(patternView.getPatternString())) {
Toast.makeText(getApplicationContext(), "PATTERN CORRECT", Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(getApplicationContext(), "PATTERN NOT CORRECT", Toast.LENGTH_SHORT).show();
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:patternview="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.screenlock.MainActivity">
<com.eftimoff.patternview.PatternView
android:id="@+id/patternView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
patternview:gridColumns="4"
patternview:gridRows="5" />
</RelativeLayout>
最佳答案
您正在使用自定义库,在此 https://github.com/geftimov/android-patternview库,数字功能不可用。所以你可以把问题放在 https://github.com/geftimov/android-patternview/issues用于库更新。
关于java - 如何在Android模式锁定中添加数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41547196/