Hi Folks, In this post i am going to show you how to create a Lock9View and create your own pattern as we have seen in Android Pattern Lock Screen. By following this tutorial you can use this Pattern Lock in you application as a security test for users before performing any task or passing to an activity.
Source code from : http://android-arsenal.com/details/1/1790
Step 1 : Create a new project by going to File ? New Android Application Project. Fill all the details and name your activity as MainActivity.
The next major step is to implement the Lock9View into our project. Before that we should place the drawables for pattern node.
Step 2 : Create a new xml file under values. Right Click on values folder ? New ? Android XML File and name it as attrs_lock_9_view.xml and fill it with following code.
Source code from : http://android-arsenal.com/details/1/1790
Step 1 : Create a new project by going to File ? New Android Application Project. Fill all the details and name your activity as MainActivity.
? Designing pattern node
The next major step is to implement the Lock9View into our project. Before that we should place the drawables for pattern node.- lock_9_view_node_highlighted.png
- lock_9_view_node_normal.png
Step 2 : Create a new xml file under values. Right Click on values folder ? New ? Android XML File and name it as attrs_lock_9_view.xml and fill it with following code.
<?xml version = "1.0" encoding = "utf-8"?> <attr name = "nodeSrc" format
<attr name = "nodeOnSrc" format
</declare-styleable >
The declare-styleable is used to set attributes to components. We have declared style attributes for Lock9View in attrs_lock_9_view.xml as shown above. These style attributes can be set in xml where the Lock9View is placed. Step 3 : Create a package under main package. Right Click on main package ? New ? Package and name after your main package as .utils. [for eg : My main package is : com.android.androiddelight.lock9view Utils package is : com.android.androiddelight.lock9view.utils] Step 4 : Create a new class under src/utils package. Right Click on src/utils package (com.android.androiddelight.lock9view.utils) ? New ? Class and name it as Lock9View.java and fill it with following code.
void onLayout(boolean changed, int left, int top, int right, int bottom) {
boolean onTouchEvent(MotionEvent event) { nodeAt.setHighLighted(true); case MotionEvent.ACTION_UP:
private void clearScreenAndDrawList() {
for (int n = 0; n < getChildCount(); n++) {
public void setCallBack(CallBack callBack) {
boolean isHighLighted() {
public interface CallBack { public void onFinish(String password); } Now we are ready with the 9 Pattern View. Next i am going to declare this view inside my main layout that is activity_main.xml. Step 5 : Open the activity_main.xml under res/layout and fill it with following code.
|
0 comments:
Post a Comment