On the Head First Android book I make a program, gives an error, when you press an error shows the Spinner object in Activity_Find_Beer.xml. From the name of the error I think that the reason is in the wrong link.
Please send to the right way
Thanks in advance for the answers!
Androidmanifest.xml
& lt; xml version = "1.0" encoding = "UTF-8"? & gt;
& lt; manifest xmlns: android = "http://schemas.android.com/apk/res/android"
package = "com.example.beeradviser2" & gt;
& lt; application
Android: AllowBackup = "True"
Android: icon = "@ MIPMAP / IC_LAUNCHER"
Android: Label = "@ String / App_name"
Android: Roundicon = "@ mipmap / ic_launcher_round"
Android: Supportsrtl = "True"
Android: Theme = "@ STYLE / APPTHEME" & GT;
& lt; Activity Android: name = ". Findbeeractivity" & gt;
& lt; INTENT-FILTER & GT;
& lt; Action Android: name = "Android.Intent.action.Main" / & gt;
& lt; Category Android: Name = "Android.intent.category.launcher" / & gt;
& lt; / Intent-Filter & GT;
& lt; / activity & gt;
& lt; / application & gt;
& lt; / manifest & gt;
Activity_find_beer.xml
& lt; xml version = "1.0" encoding = "UTF-8"? & gt;
& lt; RelativeLayout XMLNS: Android = "http://schemas.android.com/apk/res/android"
Android: Orientation = "Vertical" Android: layout_width = "match_parent"
Android: layout_height = "Match_Parent" & gt;
& lt; spinner
Android: id = "@ + ID / Color"
Android: layout_width = "Match_Parent"
Android: layout_height = "wrap_content"
Android: Layout_AlignParentTop = "True"
Android: layout_centerHorizontal = "True"
Android: layout_margintop = "37dp"
Android: Entires = "@ Array / Beer_Colors" / & gt;
& lt; button
Android: id = "@ + ID / Find_Beer"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignleft = "@ + id / color"
Android: layout_below = "@ + ID / Color"
Android: Text = "@ String / Find_Beer"
Android: OnClick = "OnClickfindbeer" / & gt;
& lt; TextView
Android: id = "@ + ID / BRANDS"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignleft = "@ + id / find_beer"
Android: Layout_Below = "@ ID / Find_Beer"
Android: layout_margintop = "18dp"
Android: text = "@ String / Brands" / & gt;
& lt; / relativeLayout & gt;
strings.xml
& lt; resources & gt;
& lt; String name = "app_name" & gt; Beer Adviser2 & LT; / String & GT;
& lt; String-Array Name = "beer_colors" & gt;
& lt; Item & gt; Light & lt; / Item & gt;
& lt; Item & gt; Amber & LT; / Item & gt;
& lt; Item & gt; brown & lt; / item & gt;
& lt; Item & gt; Dark & Lt; / Item & gt;
& lt; / String-Array & GT;
& lt; String Name = "Find_Beer" & gt; Find Beer! & lt; / String & GT;
& lt; String Name = "Brands" / & gt;
& lt; / Resources & gt;
findbeeractivity.java
package com.example.beeradviser2;
Import Android.app.ActiveIVITY;
Import android.os.Bundle;
Import Android.View.View;
Import android.widget.spinner;
Import android.widget.textView;
Public Class FindbeeRactivity Extends Activity {
@Override
PROTECTED VOID OnCreate (Bundle SavedintanceState) {
Super.ONCREATE (SavedintanceState);
setContentView (R.Layout.Activity_Find_Beer);
}
Public Void OnClickfindbeer (View View) {
TextView Brands = (TextView) FindViewByid (R.ID.Brands);
Spinner Color = (Spinner) FindViewByid (R.ID.COLOR);
String BeertyPe = String.Valueof (Color.getSelectItem ());
brands.settext (beertype);
}
}
Answer 1, Authority 100%
typo in
Android: entires = "@ Array / Beer_Colors"
Must be Entries
.