java如何制作OtpEditText和后进先出(堆栈)?
Like this https://安卓example365.com/content/images/2019/05/OtpEditText.gif if wordbox1.setText("C") get clicked wordbox1 become invisible and matchbox1.getText("C") when matchbox1 get clicked wordbox1 become visible and matchbox1.getText(null) I want check if matchbox1 , matchbox2 ,matchbox3 = getText(null) to fill who 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);
}
}
}
I hope i find the answer becase I need it very much
共 (0) 个答案