Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid hellospinner tutorial
    primarykey
    data
    text
    <p>I am doing the HelloSpinner tutorial and I am getting error markers under two areas (lines 4 and 6 of the onCreate method...i marked them )and I cant figure out why? I have used the code from the tutorial and I have not varied from their instructions. Here is my code...</p> <pre><code> package com.android.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 Activity1 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*(&lt;-this is an error).spinner); ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource( this, (*R.array*(&lt;-this is an error).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. } } }////end of class Activity1 </code></pre> <p>here is my main.xml file in layout</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>and her is my strings.xml file from my values folder</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>
    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.
 

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