Probleme mit (EditText)

D

DevelopingPhil

Neues Mitglied
1
Hallo Leute,

ich bin gerade dran einen Login zu bauen. Wenn diese LoginActivity.java gestartet wird, stürzt die App immer ab mit "Unfortunately, blabla".

Code:
public class LoginActivity extends ActionBarActivity {
	
	Button button;
	EditText usernameText;
	EditText passwordText;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
        button = (Button)findViewById(R.id.button1);
        usernameText = (EditText)findViewById(R.id.textView1);
        passwordText = (EditText)findViewById(R.id.textView2);

Habe jetzt mal den relevanten Teil hier reinkopiert. Wenn ich die letzten beiden Zeilen auskommentiere, geht es ganz normal also es muss an den EditTexts liegen. Jemand eine Idee? Mein XML Layout für den Login sieht so aus:

Code:
<TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="19dp"
        android:layout_marginRight="19dp"
        android:layout_marginTop="19dp"
        android:text="Username"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginRight="19dp"
        android:layout_marginTop="20dp"
        android:ems="10" >
        
        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_below="@+id/editText1"
        android:layout_marginTop="30dp"
        android:text="Passwort"
        android:textAppearance="?android:attr/textAppearanceMedium" />

 	<EditText
        android:id="@+id/editText2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView2"
        android:layout_below="@+id/textView2"
        android:layout_marginRight="19dp"
        android:layout_marginTop="20dp"
        android:ems="10"
        android:inputType="textPassword" />

 	<CheckBox
 	    android:id="@+id/checkBox1"
 	    android:layout_width="wrap_content"
 	    android:layout_height="wrap_content"
 	    android:layout_alignLeft="@+id/editText2"
 	    android:layout_alignRight="@+id/editText2"
 	    android:layout_below="@+id/editText2"
 	    android:layout_marginTop="28dp"
 	    android:text="eingeloggt bleiben" />

 	<Button
 	    android:id="@+id/button1"
 	    android:layout_width="wrap_content"
 	    android:layout_height="wrap_content"
 	    android:layout_alignRight="@+id/checkBox1"
 	    android:layout_below="@+id/checkBox1"
 	    android:layout_marginTop="54dp"
 	    android:text="Login" />

Eclipse gibt mir auch vorher keinen Fehler :(

MfG
Philipp
 
usernameText = (EditText)findViewById(R.id.textView1);
passwordText = (EditText)findViewById(R.id.textView2);

Ich glaube du musst hier editText1 und editText2 nehmen statt textView1 und textView2
 
Ahjo super danke :D
 
Noch ein gut gemeinter Rat. Vergib sprechende IDs, wenn du dir dein Coding nach einer längern Zeit nochmal anguckst, verstehst du nur noch die Hälfte mit IDs wie "textView1"
 

Ähnliche Themen

S
Antworten
4
Aufrufe
1.024
Sempervivum
S
R
Antworten
3
Aufrufe
1.665
Ritartet
R
A
  • Alex1978
Antworten
4
Aufrufe
825
Alex1978
A
Zurück
Oben Unten