Skip to content

Commit

Permalink
Remove Hardcoding from java
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsbirsingh committed May 14, 2018
1 parent 3c6bb80 commit 47c6ba1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/hp/quiz/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void onClick(View v) {
score+=1;
}

String finalScore = "Hi " +name+ " you have Scored " + score+" out of 10";
String finalScore = getString(R.string.hi) +name+ getString(R.string.youHaveScored)+score+ getString(R.string.ten);
Toast.makeText(getApplicationContext(),finalScore,Toast.LENGTH_LONG).show();


Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<string name="app_name">Quiz</string>
<string name="qName">Android Quiz</string>
<string name="Name"> Enter Your Name</string>
<string name="hi"> Hi \u0020 </string>
<string name="ten"> \u0020 out of 10 </string>
<string name="youHaveScored"> \u0020 you have Scored \u0020 </string>
<!--q1-->
<string name="Q1">Q1. What method you should override to use Android menu system ?</string>
<string name="Q1_Op1">onCreateOptionsMenu()</string>
Expand Down

0 comments on commit 47c6ba1

Please sign in to comment.