从启动画面切换时,Android应用程序崩溃

时间:2016-02-18 19:40:27

标签: java android xml

该应用程序上周正在运行我今天正在尝试一些操作栏教程,但由于我删除了这些代码并且我已经删除了对我所做代码的所有更改,因此它无法正常工作。我在手机上运行应用程序,所以我没有错误读出工作室会给我它拒绝启动模拟器。它只是说不幸的是,当从启动画面切换到登录或主屏幕时,Doggie已经停止了。

Splashscreen Java文件

public class SplashScreenActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    Thread splashThread = new Thread(){
    public void run() {
            try {
                sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally{
                Intent startHomeScreen = new Intent(SplashScreenActivity.this,HomeActivity.class);
                startActivity(startHomeScreen);
            }
        }
    };
    splashThread.start();
}

@Override
protected void onPause() {
    super.onPause();
    finish();
}
}
Splashscreen xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/fulllogo"
    android:id="@+id/imageView"
    android:background="#2c7134" />
</LinearLayout>

HomeActivity.java

public class HomeActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
}

public void sendProfile(View view) {
    Intent intent = new Intent(getApplicationContext(), DogProfileActivity.class);
    startActivity(intent);
}

}

首页xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="cs495capstone.edu.bsu.doggydid.HomeActivity"
android:background="@drawable/screenbackground">

<ImageView
    android:id="@+id/ddlogo"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/ddlogo"
    android:scaleType="fitCenter"
    android:layout_width="150dip"
    android:layout_height="150dip"/>


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/selectprofiletext"
    android:layout_below="@+id/ddlogo"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textColor="#2c7134"
    android:text="Select a profile or make a post:"
     />

<ImageButton
    android:layout_width="150dip"
    android:layout_height="150dip"
    android:id="@+id/dog1image"
    android:clickable="true"
    android:layout_below="@+id/selectprofiletext"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@drawable/dogpic"
    android:onClick="sendProfile"/>

<ImageButton
    android:layout_width="75dip"
    android:layout_height="75dip"
    android:id="@+id/dog1num1"
    android:background="@drawable/num1"
    android:clickable="true"
    android:layout_alignTop="@+id/dog1num2"
    android:layout_toLeftOf="@+id/dog1num2"
    android:layout_toStartOf="@+id/dog1num2" />

<ImageButton
    android:layout_width="75dip"
    android:layout_height="75dip"
    android:id="@+id/dog1num2"
    android:background="@drawable/num2"
    android:clickable="true"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/ddlogo"
    android:layout_toEndOf="@+id/ddlogo" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Add new dog"
    android:id="@+id/newdogbutton"
    android:background="#2c7134"
    android:allowUndo="true"
    android:textColor="#f3ca83"
    android:clickable="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:onClick="AddNewDog"/>

</RelativeLayout>

登录java

public class LoginActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
}

final Button submitbutton = (Button) findViewById(R.id.SubmitButton);
/** Called when the user clicks the Login button */
public void sendHome(View view) {
    Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
    startActivity(intent);
}

final Button registerbutton = (Button) findViewById(R.id.RegisterButton);
/** Called when the user clicks the register button */
public void sendRegister(View view) {
    Intent intent = new Intent(getApplicationContext(), RegistrationActivity.class);
    startActivity(intent);
}

}

清单

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".SplashScreenActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".RegistrationActivity"
        android:label="Registration" />
    <activity
        android:name=".NewDogActivity"
        android:label="Dog Information" />
    <activity
        android:name=".LoginActivity"
        android:label="Login" />
    <activity
        android:name=".HomeActivity"
        android:label="@string/title_activity_home" />
    <activity
        android:name=".DogProfileActivity"
        android:label="@string/title_activity_dog_profile"></activity>
</application>

</manifest>

样式xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

<!-- Base application theme. -->
    <!-- Customize your theme here. -->
    <item name="windowActionBar">false</item>
    <!-- colorPrimary is used for coloring the Toolbar -->
    <item name="colorPrimary">#2c7134</item>
    <!-- colorPrimaryDark is used for coloring the status bar -->
    <item name="colorPrimaryDark">#245c2a</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#f3ca83</item>
</style>



</resources>

Logcat错误读数 02-23 15:28:03.974 2186-2186 /?我/艺术:不迟到-Xcheck:jni(已经开启) 02-23 15:28:04.024 2186-2186 / cs495capstone.edu.bsu.doggydid W / System:ClassLoader引用未知路径:/data/app/cs495capstone.edu.bsu.doggydid-2/lib/x86 02-23 15:28:04.255 2186-2196 / cs495capstone.edu.bsu.doggydid我/艺术:WaitForGcToComplete被阻止132.833ms因为背景 02-23 15:28:04.332 2186-2196 / cs495capstone.edu.bsu.doggydid我/艺术:背景粘性并发标记扫描GC释放9833(405KB)AllocSpace对象,0(0B)LOS对象,0%免费,11MB / 11MB,暂停63.266ms总计74.475ms 02-23 15:28:04.367 2186-2196 / cs495capstone.edu.bsu.doggydid I / art:背景部分并发标记扫描GC释放43(1776B)AllocSpace对象,0(0B)LOS对象,25%免费,11MB / 15MB,暂停11.973ms总计21.908ms 02-23 15:28:04.374 2186-2217 / cs495capstone.edu.bsu.doggydid D / OpenGLRenderer:使用EGL_SWAP_BEHAVIOR_PRESERVED:true 02-23 15:28:04.472 2186-2217 / cs495capstone.edu.bsu.doggydid I / OpenGLRenderer:初始化的EGL,版本1.4 02-23 15:28:04.556 2186-2217 / cs495capstone.edu.bsu.doggydid W / EGL_emulation:eglSurfaceAttrib未实现 02-23 15:28:04.556 2186-2217 / cs495capstone.edu.bsu.doggydid W / OpenGLRenderer:无法在表面0xad6e0940上设置EGL_SWAP_BEHAVIOR,错误= EGL_SUCCESS 02-23 15:28:06.422 2186-2186 / cs495capstone.edu.bsu.doggydid D / AndroidRuntime:关闭VM 02-23 15:28:06.422 2186-2186 / cs495capstone.edu.bsu.doggydid E / AndroidRuntime:FATAL EXCEPTION:main                                                                               处理:cs495capstone.edu.bsu.doggydid,PID:2186                                                                               java.lang.RuntimeException:无法启动活动ComponentInfo {cs495capstone.edu.bsu.doggydid / cs495capstone.edu.bsu.doggydid.HomeActivity}:java.lang.IllegalArgumentException:AppCompat不支持当前主题功能:{windowActionBar:false ,windowActionBarOverlay:false,android:windowIsFloating:false,windowActionModeOverlay:false,windowNoTitle:false}                                                                                   在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)                                                                                   在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)                                                                                   在android.app.ActivityThread.-wrap11(ActivityThread.java)                                                                                   在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)                                                                                   在android.os.Handler.dispatchMessage(Handler.java:102)                                                                                   在android.os.Looper.loop(Looper.java:148)                                                                                   在android.app.ActivityThread.main(ActivityThread.java:5417)                                                                                   at java.lang.reflect.Method.invoke(Native Method)                                                                                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)                                                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)                                                                                引起:java.lang.IllegalArgumentException:AppCompat不支持当前主题功能:{windowActionBar:false,windowActionBarOverlay:false,android:windowIsFloating:false,windowActionModeOverlay:false,windowNoTitle:false}                                                                                   在android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:422)                                                                                   在android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:279)                                                                                   在android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:253)                                                                                   在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)                                                                                   at cs495capstone.edu.bsu.doggydid.HomeActivity.onCreate(HomeActivity.java:13)                                                                                   在android.app.Activity.performCreate(Activity.java:6237)                                                                                   在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)                                                                                   在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)                                                                                   在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)                                                                                   在android.app.ActivityThread.-wrap11(ActivityThread.java)                                                                                   在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)                                                                                   在android.os.Handler.dispatchMessage(Handler.java:102)                                                                                   在android.os.Looper.loop(Looper.java:148)                                                                                   在android.app.ActivityThread.main(ActivityThread.java:5417)                                                                                   at java.lang.reflect.Method.invoke(Native Method)                                                                                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)                                                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 02-23 15:28:10.045 2186-2186 / cs495capstone.edu.bsu.doggydid I / Process:发送信号。 PID:2186 SIG:9

0 个答案:

没有答案