如何在android模式锁中添加数字

时间:2017-01-09 11:37:34

标签: java android xml

我正在开发一个带有模式锁的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>

1 个答案:

答案 0 :(得分:0)

您使用的是自定义库,在此https://github.com/geftimov/android-patternview库中,数字功能不可用。因此,您可以在https://github.com/geftimov/android-patternview/issues中提出问题以进行库更新。