sandy Angela
sandy Angela

Reputation: 3

android studio keeps capitalising all my output messages?

am pretty new to this website so this is only my second question on here. I am trying to create a simple quiz on Android Studio and every output seems to be capitalized for some reason. Please help me to understand why and how to fix this. For instance, all my outputs look like this: "A+B" rather than "a+b" thus making them mathematically incorrect.

CODE SECTION for library of questions:

   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;
}

Sorry if this is not the structure used on the website, I am still learning how to put questions up.

CODE SECTION FOR MAIN 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();
            }
        }
    });

SOLUTION FOUND: 1)in your code add button.setTransformationMethod(null); where button is the name of your button 2)android:textAllCaps="false" in the xml files for the buttons

Upvotes: 0

Views: 70

Answers (1)

Mehrbod Khiabani
Mehrbod Khiabani

Reputation: 543

You are setting your text on Buttons. Default style of Buttons in android is to capitalize the text of the button.

You can get rid of it using attribute android:textAllCaps="false" on the default style of your buttons not your button xml.

Upvotes: 1

Related Questions