Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何制作OtpEditText和后进先出(堆栈)?_Java_Android - Fatal编程技术网

Java 如何制作OtpEditText和后进先出(堆栈)?

Java 如何制作OtpEditText和后进先出(堆栈)?,java,android,Java,Android,像这样 如果单击wordbox1.setText(“C”),则单击matchbox1时wordbox1变为不可见,matchbox1.getText(“C”)变为可见,matchbox1.getText(null) 我想检查matchbox1,matchbox2,matchbox3=getText(null)是否为空 我希望我能找到答案,因为我非常需要它 public class MainActivity extends AppCompatActivity implements View.OnC

像这样 如果单击wordbox1.setText(“C”),则单击matchbox1时wordbox1变为不可见,matchbox1.getText(“C”)变为可见,matchbox1.getText(null) 我想检查matchbox1,matchbox2,matchbox3=getText(null)是否为空

我希望我能找到答案,因为我非常需要它

public class MainActivity extends AppCompatActivity implements View.OnClickListener {


        //my answer buttons
        //if you click on any button of my question buttons look for
        // who is null first of my answer buttons
        Button matchbox1,matchbox2,matchbox3;

        //my question buttons wordbox1 = "C" wordbox2 = "A" wordbox3 = "R"
        // car is the correct answer
        Button wordbox1,wordbox2,wordbox3;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            matchbox1= (Button)findViewById(R.id.matchbox1);
            matchbox2= (Button)findViewById(R.id.matchbox2);
            matchbox3= (Button)findViewById(R.id.matchbox3);

            wordbox1= (Button)findViewById(R.id.wordbox1);
            wordbox2= (Button)findViewById(R.id.wordbox2);
            wordbox3= (Button)findViewById(R.id.wordbox3);

            //for example if matchbox1.getText(R) wordbox3.setVisibility(View.Visible);
            matchbox1.setOnClickListener(this);
            //for example if matchbox2.getText(A) wordbox2.setVisibility(View.Visible);
            matchbox2.setOnClickListener(this);
            //for example if matchbox3.getText(C) wordbox1.setVisibility(View.Visible);
            matchbox3.setOnClickListener(this);

            wordbox1.setOnClickListener(this);
            wordbox2.setOnClickListener(this);
            wordbox3.setOnClickListener(this);

        }

        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.wordbox1:

                    matchbox1.setText("C");
                    wordbox1.setVisibility(View.INVISIBLE);

                    break;

                case R.id.wordbox2:

                    matchbox2.setText("A");
                    wordbox2.setVisibility(View.INVISIBLE);

                    break;

                case R.id.wordbox3:

                    matchbox3.setText("R");
                    wordbox3.setVisibility(View.INVISIBLE);

                    break;



               //for example any button pressed
                case R.id.matchbox1:


                    wordbox3.setVisibility(View.VISIBLE);
                    matchbox1.setText("");


                    break;

                case R.id.matchbox2:


                    wordbox2.setVisibility(View.VISIBLE);
                    matchbox2.setText("");

                    break;

                case R.id.matchbox3:


                    wordbox1.setVisibility(View.VISIBLE);
                    matchbox3.setText("");

                    break;

            }

                if (matchbox1.getText().toString().equals("C") &&
                    matchbox2.getText().toString().equals("A")&&
                    matchbox3.getText().toString().equals("R")){

                     matchbox1.setBackgroundColor(Color.GREEN);
                     matchbox2.setBackgroundColor(Color.GREEN);
                     matchbox3.setBackgroundColor(Color.GREEN);


            }



        }
    }