Question: Android Studio Programming I need help with the XML portion of my app as well as the Toast messages to the user, I think the

Android Studio Programming

I need help with the XML portion of my app as well as the Toast messages to the user, I think the java code is good(of course if it isnt please let me know as well)

Here are the parameters of the app:

Create an app called GuessWho.

The point of the app will to have the user play a guessing game based on a displayed image.

The user will be greeted with a screen that has an image of a person, four buttons and a next button. The four buttons should each have a different name on it. One of the names will be the actual name of the person in the image.

Your guess who quiz should consist of at least 5 questions. Each question should have a unique image and a different correct answer.

The Model of the app should be a QuizQuestion. The QuizQuestion should have an image resource ID for the person being guessed, the strings for the four possible guesses and what the right answer is.

Your model should have appropriate constructor and get/set methods.

Your app should tell the user if they are correct if they press the button with the correct name, and your app should tell the user they are wrong if they tap the button of an incorrect name.

There should be a next button that takes the user to the next question of the quiz.

If the user completes the last question of the quiz, your app should Toast to the screen how many correct guesses they had and how many incorrect guesses they had.

If the user gets to the end of the quiz and presses next, they should go back to the first question after seeing the Toast.

For portrait orientation the image should appear first, then two guess buttons below the image, then two more guess buttons below the image, then the next button on the bottom of the screen.

For landscape orientation, the image should appear on the left side of the screen. To the right should be the 4 guess buttons. To the right of the buttons should be the next button.

(Feel free to use different layouts then these if you think they look better. The point is there should be a different landscape and portrait layout.)

The Controller Activity class should be a class called GuessWhoActivity. This should be the lone activity in your app responsible for handling user interaction and displaying questions and answers.

The view should be your xml layout files.

The app should remember what question the user was on if they switch from landscape to portrait mode. (Example: If they were on the 3rd question in portrait mode and switch to landscape, they should still be on the 3rd question when they get to landscape mode).

Make sure to not be using hard coded strings. Use strings.xml.

xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"  package="edu.waubonsee.android.guesswho"> <application  android:allowBackup="true"  android:icon="@mipmap/ic_launcher"  android:label="@string/app_name"  android:supportsRtl="true"  android:theme="@style/AppTheme"> <activity android:name=".GuessWhoActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> intent-filter> activity> application> manifest> 
xml version="1.0" encoding="utf-8"?> <LinearLayout  xmlns:android= "http://schemas.android.com/apk/res/android"  android:id="@+id/rootLayout"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:gravity="center"  android:orientation="vertical"> <ImageView  android:id="@+id/imageView"  android:layout_width="match_parent"  android:layout_height="match_parent"  /> <LinearLayout  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:orientation="horizontal"> <Button  android:id="@+id/true_button"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="@string/true_button"/> <Button  android:id="@+id/false_button"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="@string/false_button"/> <Button   android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="@string/false_button"/> <Button  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="@string/false_button"/> LinearLayout> <LinearLayout  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:orientation="horizontal"> <Button  android:id="@+id/next_button"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:="@string/next_button"/> LinearLayout> LinearLayout> 

GuessWhoActivity.java

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import android.view.View.OnClickListener; public class GuessWhoActivity extends AppCompatActivity { private static final String TAG = "GuessWho"; private static final String KEY_INDEX = "index"; Button button1, button2, button3, button4, nextButton; ImageView quizImage; int mCurrentIndex; Question questionList[] = { // add images and names  new Question(R.drawable.image, R.string.Wrong11,R.string.Wrong12,R.string.Wrong13 , R.string.Correct1 ,R.string.Correct1), new Question(R.drawable.image, R.string.Wrong21,R.string.Wrong22,R.string.Wrong23 , R.string.Correct2 ,R.string.Correct2), new Question(R.drawable.image, R.string.Wrong31,R.string.Wrong32,R.string.Wrong33 , R.string.Correct3 ,R.string.Correct3), new Question(R.drawable.image, R.string.Wrong41,R.string.Wrong42,R.string.Wrong43 , R.string.Correct4 ,R.string.Correct4), new Question(R.drawable.image, R.string.Wrong51,R.string.Wrong52,R.string.Wrong53 , R.string.Correct5 ,R.string.Correct5), new Question(R.drawable.image, R.string.Wrong61,R.string.Wrong62,R.string.Wrong63 , R.string.Correct6 ,R.string.Correct6) }; //Hello  @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_guess_who); quizImage = (ImageView) findViewById(R.id.imageView1); button1 = (Button) findViewById(R.id.btn1); button2 = (Button) findViewById(R.id.btn2); button3 = (Button) findViewById(R.id.btn3); button4 = (Button) findViewById(R.id.btn4); setResources(); nextButton = (Button) findViewById(R.id.nextButton); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0){ updateQuestion(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { quizImage.setImageResource(R.drawable.mrbean); } }); } public void updateQuestion() { mCurrentIndex = (mCurrentIndex + 1) % questionList.length; setResources(); } public void setResources() { quizImage.setImageResource(questionList[mCurrentIndex].getImageResId()); button1.setText(questionList[mCurrentIndex].getButtResId1()); button2.setText(questionList[mCurrentIndex].getButtResId2()); button3.setText(questionList[mCurrentIndex].getButtResId3()); button4.setText(questionList[mCurrentIndex].getButtResId4()); } @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); Log.i(TAG, "onSaveInstanceState"); savedInstanceState.putInt(KEY_INDEX,mCurrentIndex); } @Override public void onStart() { super.onStart(); Log.d(TAG, "onStart() called"); } @Override public void onPause() { super.onPause(); Log.d(TAG, "onPause() called"); } @Override public void onResume() { super.onResume(); Log.d(TAG, "onResume() called"); } @Override public void onStop() { super.onStop(); Log.d(TAG, "onStop() called"); } @Override public void onDestroy() { super.onDestroy(); Log.d(TAG, "onDestroy() called"); } } 

QuizQuestion.java

public class Question { //Image res ID  //Strings of four trial answer  //Correct answer gussed   private int mImageResId; private int mButtResId1, mButtResId2, mButtResId3, mButtResId4; private int mCorrectguessResId; Question(int _imageRedId, int _guess1, int _guess2, int _guess3, int _guess4, int _correctguess) { mImageResId = _imageRedId; mCorrectguessResId = _correctguess; mButtResId1 = _guess1; mButtResId2 = _guess2; mButtResId3 = _guess3; mButtResId4 = _guess4; } public int getImageResId() { return mImageResId; } public void setImageResId(int imageResId) { mImageResId = imageResId; } public int getButtResId1() { return mButtResId1; } public void setButtResId1(int buttResId1) { mButtResId1 = buttResId1; } public int getButtResId2() { return mButtResId2; } public void setButtResId2(int buttResId2) { mButtResId2 = buttResId2; } public int getButtResId3() { return mButtResId3; } public void setButtResId3(int buttResId3) { mButtResId3 = buttResId3; } public int getButtResId4() { return mButtResId4; } public void setButtResId4(int buttResId4) { mButtResId4 = buttResId4; } public int getCorrectguessResId() { return mCorrectguessResId; } public void setCorrectguessResId(int correctguessResId) { mCorrectguessResId = correctguessResId; } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!