Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HelloViews Spinner Tutorial R.id and R.array can not be resolved
    primarykey
    data
    text
    <p>I am having trouble with the Android HelloViews Spinner Tutorial. The error in HelloSpinner.java states that "R.id cannot be resolved" and "R.array cannot be resolved". The error in AndroidManifest.xml states that there is "No resource found that matches the given name (at 'label' with value '@string/app_name')" and "No resource found that matches the given name (at 'label' with value '@string/app_name')".</p> <p>Here is my complete code:</p> <p>HelloSpinner.java</p> <pre><code>package net.brianwolf.hellospinner; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; import android.widget.AdapterView.OnItemSelectedListener; public class HelloSpinner extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Spinner spinner = (Spinner) findViewById(R.id.spinner); android.widget.Spinner spinner = (android.widget.Spinner) findViewById(R.id.spinner); ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource( this, R.array.planets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); } public class MyOnItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) { Toast.makeText(parent.getContext(), "The planet is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } public void onNothingSelected(AdapterView parent) { // Do nothing. } } } </code></pre> <p>res/layout/main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="10dip" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dip" android:text="@string/planet_prompt" /&gt; &lt;Spinner android:id="@+id/spinner" android:layout_width="fill_parent" android:layout_height="wrap_content" android:prompt="@string/planet_prompt" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>res/layoutvalues/strings.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="planet_prompt"&gt;Choose a planet&lt;/string&gt; &lt;string-array name="planets_array"&gt; &lt;item&gt;Mercury&lt;/item&gt; &lt;item&gt;Venus&lt;/item&gt; &lt;item&gt;Earth&lt;/item&gt; &lt;item&gt;Mars&lt;/item&gt; &lt;item&gt;Jupiter&lt;/item&gt; &lt;item&gt;Saturn&lt;/item&gt; &lt;item&gt;Uranus&lt;/item&gt; &lt;item&gt;Neptune&lt;/item&gt; &lt;/string-array&gt; &lt;/resources&gt; </code></pre> <p>AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.brianwolf.hellospinner" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".HelloSpinner" android:label="@string/app_name"&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; </code></pre> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload