EditText auslesen

  • Antworten:2
  • GeschlossenBentwortet
Daniel B.
  • Forum-Beiträge: 45

27.06.2011, 22:44:22 via Website

Hallo,

ich bin leider so etwas am vezweifeln.


1public class Zugarchiv extends Activity {
2 /** Called when the activity is first created. */
3
4
5 @Override
6 public void onCreate(Bundle savedInstanceState) {
7 super.onCreate(savedInstanceState);
8 setContentView(R.layout.main);
9 Button save = (Button) findViewById(R.id.button1);
10 save.setOnClickListener(new View.OnClickListener() {
11 public void onClick(View v) {
12 final EditText title = (EditText) findViewById (R.id.textView1);
13 final String titel = title.getText().toString();
14 Toast.makeText(getApplicationContext(), titel, Toast.LENGTH_LONG).show();
15 }
16 });
17 }
18}

leider schließt die App immer mit einem FC. Wo liegt der Fehler?

Hier der Inhalt der Layout-Datei:
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 >
7 <DatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/datePicker1"></DatePicker>
8<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
9 android:orientation="horizontal"
10 android:layout_width="fill_parent"
11 android:layout_height="fill_parent"
12 android:layout_weight="1"
13 >
14 <TextView android:text="Zug-Nr." android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
15 <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:id="@+id/editText1"></EditText>
16</LinearLayout>
17<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18 android:orientation="vertical"
19 android:layout_width="fill_parent"
20 android:layout_height="fill_parent"
21 android:layout_weight="1"
22 >
23<TextView android:text="Bemerkungen:" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
24<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" android:id="@+id/editText2"></EditText>
25<Button android:text="Speichern" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
26</LinearLayout>
27</LinearLayout>

Daniel B.
  • Forum-Beiträge: 45

27.06.2011, 22:46:54 via Website

kann den Thread mal bitte jemand wieder schließen? habe den offensichtlichen Fehler gefunden, manchmal sieht man echt den Wald vor lauter Bäumen nicht...

San Blarnoi
  • Forum-Beiträge: 2.545

28.06.2011, 00:34:35 via Website

Ich hätte es zwar gut gefunden, wenn du die Lösung noch genannt hättest, aber gut.

@Sven: wann bekommen wir endlich formatierte Quelltexte?
Müsste ja nicht einmal mit Buntibunti sein, ich wäre mit ordentlicher Einrückung schon zufrieden...