0
....
case 5:
    sizeperbutton = sizeOfLayout/5;
    for( i = 0; i<25; i++) {
       buttons[i] = new Button(this)
       ll.addView(buttons[i]);
       ViewGroup.LayoutParams mParams = buttons[i].getLayoutParams();
       mParams.height = sizeperbutton;
       mParams.width = sizeperbutton;
       int j = (int)(Math.random()*26);
       buttons[i].setText(letterEN[j]);
       buttons[i].setTag(i);
       buttons[i].setOnTouchListener(new View.OnTouchListener() {

           @Override
           public boolean onTouch(View view, MotionEvent motionEvent) {
               Object tag = view.getTag();
               if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
                 /* Set the background drawable only for the button  I've clicked, and get its text and append it to a textView*/
               }
               if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){
                 /* Set the background drawable all the buttons I dragged through my finger and append their letters to the same textView*/
               }
               if(motionEvent.getAction() == MotionEvent.ACTION_UP){
                 /*Release touching, check if the text which is stacked to the textView is contained by a list.*/
               }
               return false;
           }
       });
  }

ゲームアクティビティで、水平方向と垂直方向に 5 つのボタンがある領域を作成します。それらはすべてランダムな文字を取得し、タッチリスナーを取得します。これは、より多くのオブジェクトを同時にクリックするには不十分だと思います.1つのボタンでしか機能しません. ソースやコードをいただければ幸いです。私は長い間調査を行ってきましたが、最終的に情報を求めなければなりませんでした。これが私が達成したいことです: https://www.youtube.com/watch?v=NRIvZioTdMc .

4

0 に答える 0