dimanche 30 août 2015

How to make a Random Layout when button clicked

Actually i want to make it Random class but then i think to much activity can make the app slow so i just want to make Relative layout Random

so i have 5 layout in one activity class

layout1 = (RelativeLayout)findViewById(R.id.layout1);
layout2 = (RelativeLayout)findViewById(R.id.layout2);
layout3 = (RelativeLayout)findViewById(R.id.layout3);
layout4 = (RelativeLayout)findViewById(R.id.layout4);  
layout5 = (RelativeLayout)findViewById(R.id.layout5);

and in each layout there is the button in there to make layout random again

button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v){ 

        //The code to how make layout random

        }
     });
 }

and then how to make layout that already opened not open again if the button random was pressed? then if all layout was already opened it will open new activity class

can anyone help me explain with give some example code of that?




Aucun commentaire:

Enregistrer un commentaire