I am making my own Pattern Lock for android phone, i have Done the coding as when i click on an image it stores an integer in an array and when the user re-enters the same password it matches both the arrays and Open the lock accordingly, my code is working fine But Now i have to add gesture in the form of a line while going from one image to another (as in pattern lock) also i want to store the integers in the array when i touch an image instead of clicking it...
guide me how to do this below is my sample code for image click events
public void Image1(View view) {
// Toast.makeText(this, "You clicked Image 1!",
// Toast.LENGTH_SHORT).show();
myArray[0] = 1;
// builder.append("" + myArray[0] + " ");
// Toast.makeText(this, myArray, Toast.LENGTH_LONG).show();
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image2(View view) {
// Toast.makeText(this, "You clicked Image 2!",
// Toast.LENGTH_SHORT).show();
myArray[1] = 2;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image3(View view) {
// Toast.makeText(this, "You clicked Image 3!",
// Toast.LENGTH_SHORT).show();
myArray[2] = 3;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image4(View view) {
// Toast.makeText(this, "You clicked Image 4!",
// Toast.LENGTH_SHORT).show();
myArray[3] = 4;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image5(View view) {
// Toast.makeText(this, "You clicked Image 5!",
// Toast.LENGTH_SHORT).show();
myArray[4] = 5;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image6(View view) {
// Toast.makeText(this, "You clicked Image 6!",
// Toast.LENGTH_SHORT).show();
myArray[5] = 6;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image7(View view) {
// Toast.makeText(this, "You clicked Image 7!",
// Toast.LENGTH_SHORT).show();
myArray[6] = 7;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image8(View view) {
// Toast.makeText(this, "You clicked Image 8!",
// Toast.LENGTH_SHORT).show();
myArray[7] = 8;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
public void Image9(View view) {
// Toast.makeText(this, "You clicked Image 9!",
// Toast.LENGTH_SHORT).show();
myArray[8] = 9;
ImageView kk = (ImageView) view;
Drawable d = getResources().getDrawable(R.drawable.unlock);
kk.setImageDrawable(d);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…