Uber neu zu Programmierung, aber habe angefangen zu versuchen, eine wirklich einfache App mit einem Tutorial (https://developer.android.com/training/basics/firstapp/starting-activity.html) machen, aber ich habe in ein paar Straßenblöcke gelaufen. Ich habe versucht, diese App zweimal zu machen und scheiterte kläglich. Ein Problem ist, dass die viewGroup
Zeile aus dem Code verschwindet, sobald sie eingegeben wird. Das zweite Problem ist, dass die App abstürzt, sobald sie startet. Ich hatte anfangs die erste Aktivität, aber die App stürzte ab, wenn auf die Schaltfläche geklickt wurde. Ich habe das Triad sauber/neu aufgebaut, aber es hat überhaupt nicht geholfen. Ich habe auch andere grundlegende Informationen ausprobiert, die ich gerne bearbeiten oder entfernen würde, aber sie haben auch nicht geholfen. In diesem Stadium würde jede und jede Hilfe sehr geschätzt werden! Danke im Voraus!App hält weiter an - startet nicht
Logcat Fehler info
06-14 20:56:40.335 25791-25791/com.example.jacqueline.myfirstapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jacqueline.myfirstapp, PID: 25791
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jacqueline.myfirstapp/com.example.jacqueline.myfirstapp.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2711)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2772)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6217)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:359)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.jacqueline.myfirstapp.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6705)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2664)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2772)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6217)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
zentral- -
package com.example.jacqueline.myfirstapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
public static final String EXTRA_MESSAGE = "com.example.jacqueline.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**called when user taps the send button*/
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
public class EXTRA_MESSAGE {
}
}
Sein geschrieben - müssen Sie Ihr Thema der App spezifizieren. auf dem Manifest: android: theme = "@ style/AppTheme" verursacht durch: java.lang.IllegalStateException: Sie müssen ein Theme.AppCompat-Thema (oder einen Nachkommen) mit dieser Aktivität verwenden. – Dus