D
donhenne
Neues Mitglied
- 0
Hallo!
Bin noch recht neu im Android-Gebiet und versuche gerade Werte an eine andere Activity weiterzureichen. Mein Problem ist, dass ich alle Werte gebündelt an die nächste Activity weitergeben und anzeigen lassen möchte, ich es aber nicht hinkriege. Habe schon alles mögliche mit putExtra(), getExtra() etc ausproiert. Code da schon ewig dran rum.
Vielleicht kann ja wer helfen
Hier mal der Code:
start.java:
ergebnis.java
main.xml
ergebnis_anzeigen.xml
Bin noch recht neu im Android-Gebiet und versuche gerade Werte an eine andere Activity weiterzureichen. Mein Problem ist, dass ich alle Werte gebündelt an die nächste Activity weitergeben und anzeigen lassen möchte, ich es aber nicht hinkriege. Habe schon alles mögliche mit putExtra(), getExtra() etc ausproiert. Code da schon ewig dran rum.
Vielleicht kann ja wer helfen
Hier mal der Code:
start.java:
Code:
public class start extends Activity {
/** Called when the activity is first created. */
// Variablen fuer die einzelnen Menueeintraege
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Autocomplete fuer Strassen
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_strassen);
String[] strasse = getResources()
.getStringArray(R.array.strassen_array);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.list_item, strasse);
textView.setAdapter(adapter);
// Spinner fuer Monateauswahl
final Spinner spinner1 = (Spinner) findViewById(R.id.Spinner01);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(
this, R.array.monate_array,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter1);
// Spinner fuer Jahreauswahl
Spinner spinner2 = (Spinner) findViewById(R.id.Spinner02);
ArrayAdapter<CharSequence> adapter2 = ArrayAdapter
.createFromResource(this, R.array.jahre_array,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(adapter2);
// Spinner fuer Muellauswahl
Spinner spinner4 = (Spinner) findViewById(R.id.Spinner04);
ArrayAdapter<CharSequence> adapter4 = ArrayAdapter
.createFromResource(this, R.array.muell_array,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner4.setAdapter(adapter4);
}
// Ergebnis anzeigen
public void ergebnisAufruf(View v) {
Intent intent = new Intent(this, ergebnis.class);
startActivity(intent);
}
// zurück zum Anfangsbildschirm
public void backToMain(View v) {
Intent intent = new Intent(this, start.class);
startActivity(intent);
}
}
Code:
public class ergebnis extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.ergebnis_anzeigen);
}
public void backToMain(View v) {
Intent intent = new Intent(this, start.class);
startActivity(intent);
}
}
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" android:background="@color/hintergrund">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textColor="@color/schrift"
android:text="Wählen Sie Ihre Straße und die gewünschte Abfallart aus." />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strasse" />
<AutoCompleteTextView android:id="@+id/autocomplete_strassen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Monat" />
<Spinner android:id="@+id/Spinner01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:entries="@array/monate_array" android:drawSelectorOnTop="true"></Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jahr" />
<Spinner android:id="@+id/Spinner02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:entries="@array/jahre_array" android:drawSelectorOnTop="true"></Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Müllart" />
<Spinner android:id="@+id/Spinner04" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:entries="@array/muell_array" android:drawSelectorOnTop="true"></Spinner>
<Button android:text="Anzeigen" android:id="@+id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:onClick="ergebnisAufruf"></Button>
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/logo" android:layout_gravity="center_horizontal"></ImageView>
</LinearLayout>
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/hintergrund">
<View android:layout_height="2dip" android:background="#FFC43B" />
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Art"
android:padding="3dip"></TextView>
<TextView android:text="Datum" android:id="@+id/TextView02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="3dip"></TextView>
<TextView android:text="Text" android:id="@+id/TextView03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="3dip"></TextView>
</TableRow>
<View android:layout_height="2dip" android:background="#FFC43B" />
<Button android:text="zurück" android:id="@+id/Button02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:onClick="backToMain"></Button>
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/logo" android:layout_gravity="center_horizontal"></ImageView>
</TableLayout>