我对这个网站还很陌生,所以这只是我的第二个问题。 我正在尝试在 Android Studio 上创建一个简单的测验,但由于某种原因,每个输出似乎都是大写的。请帮助我理解为什么以及如何解决这个问题。 例如,我的所有输出看起来都是这样的:“A+B”而不是“a+b”,因此在数学上它们是不正确的。
问题库的代码部分:
private String mQuestions[] =
{"Prove the simplest form of the following equation:"+expression+"(4n+1)(n+8)-"+expression+"n(4n+1)",
"A rectangle of sides a"+expressioncube+" and a"+expressionsquare+". Prove its perimeter algebraically",
"Which of the following represents two consecutive square numbers where n is a positive integer?",
"For the equation a"+expressionsquare+"=25. The only value that a can hold is 5" ,
"If my rectangle has a perimeter of 2a+2b , what is its area?"};
private String mChoices[][] = {
{"4n+1", "n+1","n+8"},
{answer2, answer3,answer4},
{answer5+"and "+expressionsquare+"+2", answer5+"and "+answer6 ,answer5+"and "+answer7},
{"True", "False","Unsure"},
{"a+b", "ab","2(a+b)"}};
private String mCorrectAnswers[] = {"4n+1", answer3 , answer5+"and "+answer7, "False", "ab"};
public String getQuestion (int a){
String question = mQuestions[a];
return question;
}
public String getChoice1 (int a){
String choice0 = mChoices[a][0];
return choice0;
}
public String getChoice2 (int a){
String choice1 = mChoices[a][1];
return choice1;
}
public String getChoice3 (int a){
String choice2 = mChoices[a][1];
return choice2;
}
public String getCorrectAnswers (int a){
String answer = mCorrectAnswers[a];
return answer;
}
抱歉,如果这不是网站上使用的结构,我仍在学习如何提出问题。
主要 Activity 的代码部分:
mScoreView=(TextView)findViewById(R.id.score);
mQuestionView=(TextView)findViewById(R.id.question);
mButtonChoice1=(Button)findViewById(R.id.choice1);
mButtonChoice2=(Button)findViewById(R.id.choice2);
mButtonChoice3=(Button)findViewById(R.id.choice3);
updateQuestion();
//start the button listener button1
mButtonChoice1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view){
if(mButtonChoice1.getText()==mAnswer){
mScore=mScore+1;
updateScore(mScore);
updateQuestion();
Toast.makeText(Algebraiexpressions.this, "Well Done", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(Algebraiexpressions.this, "Next Time", Toast.LENGTH_SHORT).show();
updateQuestion();
}
}
});
找到解决方案: 1)在您的代码中添加button.setTransformationMethod(null); 其中,button 是按钮的名称 2)按钮的 xml 文件中的 android:textAllCaps="false"
最佳答案
您正在按钮
上设置文本。 Android 中 Button
的默认样式是按钮文本大写。
您可以在按钮的默认样式而不是按钮 xml 上使用属性 android:textAllCaps="false"
来摆脱它。
关于java - android studio 不断将我的所有输出消息大写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54534348/