CEIS320 Lab 6 – Spinners and Lists – With Screenshots – Perfect Solution – Instant Delivery

Lab Price = $18
Please feel free to send us your queries at: support@iqrajavaid.com
Payment methods

Add to Cart

Buy Now

View Cart

Problem Statement

Week 6: Lab Overview

Lab 6: Spinners and Lists (50 points)
Lab Overview
The purpose of this lab is to add on to our app by creating an information page containing spinners and lists. This will involve working with string arrays and spinners. Just as with your previous labs, you need to keep debugging your program until it runs on your device or emulator. When you are finished creating your application, submit all of your open-source files and .apk.
Your project will include the following.
• Open-source java files
• Zipped project folder
The deliverable for this lab is a zipped project folder.
Required Software
This lab will use the following Lab Resources.
• Android Studio
Use a personal copy of the software or to access the Lab Resources, go to the Lab Resources section of the Course Resources page.
Lab Steps
Step 1: Spinners and Lists
Watch this video about spinners and lists in Android.
We will be adding to our project from the previous weeks. Open Android Studio and your IntroAndroidApp you have been working on.
We will be adding an information page that the user will be directed to from the main menu.
Right-click on the app and choose New->Activity->Basic Activity. Then name the new activity InformationPageActivity. This new activity will contain several new widgets including a drop-down list box (spinner). First we need to edit the res/values/strings.xml file and add a few strings.
Your Information
What is your favorite season?
What is your favorite temperature?
Do you have allergies?
In addition to these strings, we need to add a string array for our spinner. Add this below the other strings in the strings.xml file.


Save your work.
Edit the content_information_page.xml and add the following widgets in this order.
• TextView
• TextView
• Spinner (id should be spnSeason)
• TextView
• Seek bar (id should be skbTemp; make this wider)
• TextView (to the right of the seekbar)
• TextView (placeholder for value of seekbar; this will be a small text box below the seekbar, id should be lblSeekValue)
• TextView
• Switch (id should be swchAllergy)
Change all of the TextView text so that it displays the new strings in the strings.xml file. Feel free to format the TextViews as you like. The seekbar text view will have the text property of 120 and should have the android:layout_toRightOf property set to the seekbar. See the image below.

Go to the xml layout view of your activity and add the array of strings to your spinner (code in bold).

Then set the range of temperatures for your seekbar. By default, the seekbar is set from 0 to 100. We will set the max temperature to 120 (some people like it hot!) and the default to 70.
Add the code in bold.

You also need to add the code for your switch. Please note you can add “yes” and “no” as string resources, as well, rather than just typing it into the xml. Add the bold code to the switch.

Now we will add the code to our MainMenuActivity.java so that when the user clicks on the Info button it will open our information activity page.
Add the following function.


Then add the following code in your onCreate method.
Button btnInfo=(Button) findViewById(R.id.btnInfo);
btnInfo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Now test your app by running it in the emulator and clicking on the Info button from your main menu. Your info page should show up and you should be able to click the drop-down box. We will add code to handle these values later.
Click image to enlarge

Step 2: Adding Java to Handle Lists
Now that we have created our page, we would like to store this data and pass it to another activity. Passing data between activities is done with an intent. We used the startActivity method to start an activity specified by the intent. We will also pass data from one activity to another using an intent.
First create a new activity named InformationResultsActivity. Leave InformationResultsActivity for now. We will add to it later.
Go back to the content_information_page.xml and add a button that the user will click when they are finished. Add the button at the bottom of the screen with an id of btnSave and the text should say Save.
In the InformationPageActivity.java, we will add code to handle the user input. Modify the class name so that it implements OnClickListener (you may have to press Alt+Enter) and add the variables below.
public class InformationPageActivity extends AppCompatActivity implements View.OnClickListener{
Button btnSave;
Spinner spnSeason;
SeekBar skbTemp;
Switch swchAllergy;
TextView lblSeekValue;

Add the following code to your onCreate method.
spnSeason = (Spinner) findViewById(R.id.spnSeason);
skbTemp = (SeekBar) findViewById(R.id.skbTemp);
swchAllergy = (Switch) findViewById(R.id.swchAllergy);
lblSeekValue = (TextView) findViewById(R.id.lblSeekValue);
btnSave = (Button) findViewById(R.id.btnSave);

You also need to display the value of the seekbar. In order to do that, you will need to set the listener and input the code to display the value of the seekbar (known as progress) in the placeholder text view (go ahead and remove any default text you put in the lblSeekValue TextView).
Add the following code below the btnSave.setOnClickListener(this); to display the seek bar value.
skbTemp.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
String display = String.valueOf(progress);

public void onStartTrackingTouch(SeekBar seekBar) {


public void onStopTrackingTouch(SeekBar seekBar) {

The button onClick method implementation will be a little more complicated. We want to save the values the user inputs and then pass the data to another activity. We will use the putExtra and getExtra intent class methods. These work with most primitive types and arrays. Your button onClick listener should look like this.
public void onClick(View v) {
String season, allergies;
int temperature;
season = spnSeason.getSelectedItem().toString();
allergies = (String) (swchAllergy.isChecked() ? swchAllergy
.getTextOn() : swchAllergy.getTextOff()); //if the switch is on then the user has allergies
Intent intent = new Intent(InformationPageActivity.this, InformationResultsActivity.class); //pass information to the results activity
intent.putExtra(“season”, season);
intent.putExtra(“temperature”, temperature);
intent.putExtra(“allergies”, allergies);
In order to retrieve the information and display it to the screen, go to the content_information_results.xml page and add three TextViews: txtSeason, txtTemperature, and txtAllergies, as well as a button that reads Back to Main and is named btnMain.
Next go to the InformationResultsActivity.java to retrieve the values from the intent. We will use the getStringExtra and the getIntExtra to retrieve those values from the intent. Add the following code to the onCreate method.
Intent intent = getIntent();
String season= intent.getStringExtra(“season”);
int temperature=intent.getIntExtra(“temperature”, 70); //if no int value exists then the method returns the default value
String allergies = intent.getStringExtra(“allergies”);

TextView txtSeason = (TextView) findViewById(R.id.txtSeason);
TextView txtTemperature = (TextView) findViewById(R.id.txtTemperature);
TextView txtAllergies = (TextView) findViewById(R.id.txtAllergies);
txtSeason.setText(“Your favorite season is “+season);
txtTemperature.setText(“Your favorite temperature is “+temperature);

//Depending on whether the allergies are yes or no determines the output of this textbox
txtAllergies.setText(“Sorry that you have allergies”);
txtAllergies.setText(“You don’t have allergies”);
You will also need to add code so that this page will go back to main when the user is finished with it. So code will be added in onCreate.
Button btnMain = (Button) findViewById(R.id.btnMain);
btnMain.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

And a private helper function will be added to start the intent.
private void goMain() {
Intent intent = new Intent(InformationResultsActivity.this, MainMenuActivity.class);

Run your program in the emulator and test it with different values. Press the Info button on the main menu, fill the information, and then click Save. A new activity should open showing your results. Then click Back to the main menu button.
Click image to enlarge

Click image to enlarge

Step 3: Submission
Save and zip your entire project workspace and directory files (which must include all of your open-source files) and submit them.
Don’t forget to submit your lab.


Relevant Material

Lab 6: Game Tie

Lab 6: Game Win
Lab 6: Game Win

Lab 6: Menu width=

Lab 6: My Drawing
Lab 6: My Drawing
Lab 6: Temperature
Lab 6: Temperature
Lab 6: Temperature
Lab 6: Info Page
Lab 6: Info Result
Lab 6: Info Result
* If you want to purchase multiple products then click on “Buy Now” button which will give you ADD TO CART option.Please note that the payment is done through PayPal.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at support@iqrajavaid.com.
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at support@iqrajavaid.com and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at support@iqrajavaid.com.
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Privacy Policy
We take your privacy seriously and will take all measures to protect your personal information.
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
Refund Policy
Incase you face any issues with the tutorial, please free to contact us on support@iqrajavaid.com
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.
Payment Details
Lab Price = $18
Please feel free to send us your queries at: support@iqrajavaid.com
Payment methods

Add to Cart

Buy Now

View Cart