
Lucifera Engelmacher
Neues Mitglied
- 0
Guten Tag
Ich hätte eine Frage...
Steh noch ganz am anfang mit Android.
Ich habe mir das E-Book Android - Grudlagen und Programmierung geholt. Da ist die erste aufgabe darin den Staumelder zu programmieren. Bei mir werden die RadioButtons angezeigt. aber der Spinner nicht...?
Kennt jemand schon das problem?
Wäre echt froh wenn mir jemand hier helfen könnte! bin halb am verzweifeln...:S
danke schon im Voraus!
und hier ist der Code:
###################################################
hier das xml. also mein main.xml code. die ist im ordner layout drin:
####################################################
und im ordner value habe ich dann noch die datei array.xml für den spinner:
im ordner values ist noch eine datei string.xml. aber die ist schon am anfang vorhanden.
Ich hätte eine Frage...
Steh noch ganz am anfang mit Android.
Ich habe mir das E-Book Android - Grudlagen und Programmierung geholt. Da ist die erste aufgabe darin den Staumelder zu programmieren. Bei mir werden die RadioButtons angezeigt. aber der Spinner nicht...?
Kennt jemand schon das problem?
Wäre echt froh wenn mir jemand hier helfen könnte! bin halb am verzweifeln...:S
danke schon im Voraus!
und hier ist der Code:
Code:
package yp.stau.lv;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class StauActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
//Spinner
Spinner s1 = (Spinner)findViewById(R.id.stauUrsache);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(
this, R.array.stauUrsachen,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
}
}
###################################################
hier das xml. also mein main.xml code. die ist im ordner layout drin:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/
apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<RadioGroup android:id="@+id/position"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton android:id="@+id/stauAnfang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stauanfang" />
<RadioButton android:id="@+id/stauEnde"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stauende" />
</RadioGroup>
<Spinner android:id="@+id/stauUrsache"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true" />
</LinearLayout>
und im ordner value habe ich dann noch die datei array.xml für den spinner:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="stauUrsachen">
<item>Unfall</item>
<item>Baustelle</item>
<item>Gaffer</item>
<item>Überlastung</item>
<item>Sonstige</item>
</array>
</resources>
im ordner values ist noch eine datei string.xml. aber die ist schon am anfang vorhanden.