我的应用程序有一个按钮,当按下该按钮时,它将在textView中显示一个新单词,并在editText中显示一个新提示。尽管当用户点击屏幕上的任何位置时,其效果都与按钮相同,但这显然可能导致用户误入歧途并破坏体验。任何人都可以推荐任何东西。这是按钮的Java:
public void nextWord(View view) { //nextWord is the onclick of the button
Button nextButton = findViewById(R.id.nextButton);
Button showTextButton = findViewById(R.id.showTextButton);
TextView wordTextView = findViewById(R.id.wordTextView);
EditText editTextView = findViewById(R.id.enterEditText);
ImageView logoImageView = findViewById(R.id.logoImageView);
TextView wordTextView1 = findViewById(R.id.wordTextView1);
i++;
String displayHint;
String displayText;
displayText = enterWord() + chooseArray();
displayHint = chooseArray();
wordTextView.setText(displayText);
editTextView.setHint(displayHint);
wordTextView1.setText(displayText) ;
if (i == 1) {
wordTextView.setVisibility(View.VISIBLE);
editTextView.setVisibility(View.VISIBLE);
logoImageView.setVisibility(View.INVISIBLE);
wordTextView1.setVisibility(View.VISIBLE);
// wordTextView.setText(enterWord() + initial(0));
// editTextView.setHint(initial(0));
}
if (choice == 5 && i ==1) {
pickImageButton.setVisibility(View.VISIBLE);
nextButton.setVisibility(View.INVISIBLE);
editTextView.setVisibility(View.INVISIBLE);
}else{
nextButton.setVisibility(View.VISIBLE);
editTextView.setVisibility(View.VISIBLE);
pickImageButton.setVisibility(View.INVISIBLE);
}
if (i == arrayLen()) {
showTextButton.setVisibility(View.VISIBLE);
editTextView.setVisibility(View.INVISIBLE);
wordTextView.setVisibility(View.INVISIBLE);
nextButton.setVisibility(View.INVISIBLE);
wordTextView1.setVisibility(View.INVISIBLE);
}
enteredWords[i] = editTextView.getText().toString();
}
这里是按钮的XML:
<Button
android:id="@+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:onClick="nextWord"
android:text="Next"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/enterEditText"
app:layout_constraintVertical_bias="0.0" />
尝试更改按钮的大小(更改宽度或高度),如果不起作用,请尝试将按钮重新创建为div