S
studien
Neues Mitglied
- 0
Hallo, mein Code ist folgender:
und ich bekomme diese Nachricht:
wie bekomme ich das zum Laufen?
Code:
public class Passwortaendern extends Activity implements View.OnClickListener{
Button change;
TextView antwort;
EditText pwold;
EditText pwnew1;
EditText pwnew2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.abfrage);
ansicht();
change.setOnClickListener(this);
}
private void ansicht() {
// TODO Auto-generated method stub
change = (Button) findViewById(R.id.pwch);
antwort = (TextView) findViewById(R.id.chantwort);
pwold = (EditText) findViewById(R.id.pwold);
pwnew1 = (EditText) findViewById(R.id.pwnew1);
pwnew2 = (EditText) findViewById(R.id.pwnew2);
}
public void onClick(View view) {
// TODO Auto-generated method stub
String checkpwold = pwold.getText().toString();
String checkpwnew1 = pwnew1.getText().toString();
String checkpwnew2 = pwnew2.getText().toString();
String password = "left";
antwort.setText(checkpwold);
if (checkpwold.contentEquals("left")){
if (checkpwnew1.contentEquals(checkpwnew2)){
antwort.setText("Password geändert");
antwort.setGravity(Gravity.CENTER);
antwort.setTextColor(Color.GREEN);
}
}else{
antwort.setText("Eingaben überprüfen");
antwort.setGravity(Gravity.CENTER);
antwort.setTextColor(Color.RED);
}
}
}
und ich bekomme diese Nachricht:
Code:
01-06 18:49:44.567: D/dalvikvm(5988): GC_EXTERNAL_ALLOC freed 42K, 50% free 2739K/5379K, external 319K/587K, paused 29ms
01-06 18:49:45.728: D/AndroidRuntime(5988): Shutting down VM
01-06 18:49:45.728: W/dalvikvm(5988): threadid=1: thread exiting with uncaught exception (group=0x40103560)
01-06 18:49:45.738: E/AndroidRuntime(5988): FATAL EXCEPTION: main
01-06 18:49:45.738: E/AndroidRuntime(5988): java.lang.RuntimeException: Unable to start activity ComponentInfo{test.projekt.manuel/test.projekt.manuel.Passwortaendern}: java.lang.ClassCastException: android.widget.TextView
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.os.Looper.loop(Looper.java:130)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread.main(ActivityThread.java:3835)
01-06 18:49:45.738: E/AndroidRuntime(5988): at java.lang.reflect.Method.invokeNative(Native Method)
01-06 18:49:45.738: E/AndroidRuntime(5988): at java.lang.reflect.Method.invoke(Method.java:507)
01-06 18:49:45.738: E/AndroidRuntime(5988): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
01-06 18:49:45.738: E/AndroidRuntime(5988): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
01-06 18:49:45.738: E/AndroidRuntime(5988): at dalvik.system.NativeStart.main(Native Method)
01-06 18:49:45.738: E/AndroidRuntime(5988): Caused by: java.lang.ClassCastException: android.widget.TextView
01-06 18:49:45.738: E/AndroidRuntime(5988): at test.projekt.manuel.Passwortaendern.ansicht(Passwortaendern.java:37)
01-06 18:49:45.738: E/AndroidRuntime(5988): at test.projekt.manuel.Passwortaendern.onCreate(Passwortaendern.java:28)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-06 18:49:45.738: E/AndroidRuntime(5988): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
01-06 18:49:45.738: E/AndroidRuntime(5988): ... 11 more
wie bekomme ich das zum Laufen?