Try to search your question here, if you can't find : Ask Any Question Now ?

Change position of buttons in Android

HomeCategory: stackoverflowChange position of buttons in Android
Avatarrupesh asked 5 months ago

I would exchange position of buttons in Android. For this I wrote this code:

float sayi1x = sayib1.getX();
float sayi2x = sayib2.getX();
float sayi3x = sayib3.getX();
float sayi4x = sayib4.getX();
float sayi5x = sayib5.getX();
float sayi6x = sayib6.getX();
float sayi7x = sayib7.getX();
float sayi8x = sayib8.getX();
float sayi9x = sayib9.getX();

float sayi1y = sayib1.getY();
float sayi2y = sayib2.getY();
float sayi3y = sayib3.getY();
float sayi4y = sayib4.getY();
float sayi5y = sayib5.getY();
float sayi6y = sayib6.getY();
float sayi7y = sayib7.getY();
float sayi8y = sayib8.getY();
float sayi9y = sayib9.getY();

ArrayList<Integer> sayibtnsayi = new ArrayList<>();

for(int i=0; i < 10; i++){
    sayibtnsayi.add(i);
}

Collections.shuffle(sayibtnsayi);

int kacincibuton = -1;

String btnad;

for(int ii=0; ii < 10; ii++){

    kacincibuton++;

    btnad = "sayib"+kacincibuton;

    if(sayibtnsayi.get(ii) == 1){
        imagebtns[kacincibuton].setX(sayi1x);
        imagebtns[kacincibuton].setY(sayi1y);
    } 
    else if(sayibtnsayi.get(ii) == 2){
        imagebtns[kacincibuton].setX(sayi2x);
        imagebtns[kacincibuton].setY(sayi2y);
    }
    else if(sayibtnsayi.get(ii) == 3){
        imagebtns[kacincibuton].setX(sayi3x);
        imagebtns[kacincibuton].setY(sayi3y);
    }
    else if(sayibtnsayi.get(ii) == 4){
        imagebtns[kacincibuton].setX(sayi4x);
        imagebtns[kacincibuton].setY(sayi4y);
    }
    else if(sayibtnsayi.get(ii) == 5){
        imagebtns[kacincibuton].setX(sayi5x);
        imagebtns[kacincibuton].setY(sayi5y);
    }
    else if(sayibtnsayi.get(ii) == 6){
        imagebtns[kacincibuton].setX(sayi6x);
        imagebtns[kacincibuton].setY(sayi6y);
    }
    else if(sayibtnsayi.get(ii) == 7){
        imagebtns[kacincibuton].setX(sayi7x);
        imagebtns[kacincibuton].setY(sayi7y);
    }
    else if(sayibtnsayi.get(ii) == 8){
        imagebtns[kacincibuton].setX(sayi8x);
        imagebtns[kacincibuton].setY(sayi8y);
    }
    else if(sayibtnsayi.get(ii) == 9){
        imagebtns[kacincibuton].setX(sayi9x);
        imagebtns[kacincibuton].setY(sayi9y);
    }
}

But when I start exchange of buttons, I get error: “application has stopped”

How can I resolve this problem-error?

Or do you have a code, different advice?

I wait for anyone’s help.

I hope you can understand my question. Pardon me for my bad English.

1 Answers
Best Answer
AvatarJyoti answered 5 months ago
Your Answer

9 + 10 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com