0

メインとスタディの2つのクラスがあります。メインのレイアウトで「スタディ」ボタンを押すと、スタディ クラスに移動するはずですが、代わりにアプリケーションがクラッシュします。

これはメインクラスのコードです:

package com.example.geograpp;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;

public class Main extends Activity implements OnClickListener {

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

        View studyButton=this.findViewById(R.id.study_button);
        studyButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.study_button: 
                 Intent studyIntent = new Intent(this, Study.class);
                 startActivity(studyIntent);
                 break;
        }
    }
}

これはメインのレイアウトです:

    <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=".Main" 
    android:background="@drawable/mainmenu_background">

    <Button
        android:id="@+id/study_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="94dp"
        android:text="Study" 
        android:textColor="@color/white"
        android:textSize="22sp"
        android:background="@color/black"/>

    <Button
        android:id="@+id/about_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/game_button"
        android:layout_below="@+id/game_button"
        android:layout_marginTop="40dp"
        android:background="@color/black"
        android:text="About"
        android:textColor="@color/white"
        android:textSize="22sp" />

    <Button
        android:id="@+id/game_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/study_button"
        android:layout_below="@+id/study_button"
        android:layout_marginTop="38dp"
        android:background="@color/black"
        android:text="Game"
        android:textColor="@color/white"
        android:textSize="22sp" />

    <Button
        android:id="@+id/exit_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/about_button"
        android:layout_alignRight="@+id/study_button"
        android:layout_below="@+id/about_button"
        android:layout_marginTop="42dp"
        android:background="@color/black"
        android:text="Exit"
        android:textColor="@color/white"
        android:textSize="22sp" />

</RelativeLayout>

これはスタディクラスのコードです:

package com.example.geograpp;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class Study extends Activity {

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


}

これはスタディのレイアウトです:

<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=".Study" 
    android:background="@drawable/study_background">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="106dp"
        android:text="Choose a Continent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/white" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/worldmap_clickable" />

</RelativeLayout>

これがマニフェストです

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.geograpp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="10" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.geograpp.Main"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.geograpp.Study"
            android:label="@string/title_activity_study" >
        </activity>
    </application>

</manifest>

つぶれた後の丸太猫:

09-04 22:54:17.176: D/dalvikvm(334): GC_EXTERNAL_ALLOC freed 49K, 53% free 2551K/5379K, external 1625K/2137K, paused 135ms
09-04 22:54:45.306: D/dalvikvm(334): GC_EXTERNAL_ALLOC freed 12K, 53% free 2577K/5379K, external 23321K/25369K, paused 62ms
09-04 22:54:45.396: E/dalvikvm-heap(334): 22216740-byte external allocation too large for this process.
09-04 22:54:45.496: E/GraphicsJNI(334): VM won't let us allocate 22216740 bytes
09-04 22:54:45.506: D/dalvikvm(334): GC_FOR_MALLOC freed <1K, 53% free 2577K/5379K, external 23321K/25369K, paused 35ms
09-04 22:54:45.506: D/skia(334): --- decoder->decode returned false
09-04 22:54:45.506: D/AndroidRuntime(334): Shutting down VM
09-04 22:54:45.506: W/dalvikvm(334): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-04 22:54:45.538: E/AndroidRuntime(334): FATAL EXCEPTION: main
09-04 22:54:45.538: E/AndroidRuntime(334): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.geograpp/com.example.geograpp.Study}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.os.Looper.loop(Looper.java:123)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread.main(ActivityThread.java:3683)
09-04 22:54:45.538: E/AndroidRuntime(334):  at java.lang.reflect.Method.invokeNative(Native Method)
09-04 22:54:45.538: E/AndroidRuntime(334):  at java.lang.reflect.Method.invoke(Method.java:507)
09-04 22:54:45.538: E/AndroidRuntime(334):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-04 22:54:45.538: E/AndroidRuntime(334):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-04 22:54:45.538: E/AndroidRuntime(334):  at dalvik.system.NativeStart.main(Native Method)
09-04 22:54:45.538: E/AndroidRuntime(334): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-04 22:54:45.538: E/AndroidRuntime(334):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-04 22:54:45.538: E/AndroidRuntime(334):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.Activity.setContentView(Activity.java:1657)
09-04 22:54:45.538: E/AndroidRuntime(334):  at com.example.geograpp.Study.onCreate(Study.java:12)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-04 22:54:45.538: E/AndroidRuntime(334):  ... 11 more
09-04 22:54:45.538: E/AndroidRuntime(334): Caused by: java.lang.reflect.InvocationTargetException
09-04 22:54:45.538: E/AndroidRuntime(334):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-04 22:54:45.538: E/AndroidRuntime(334):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-04 22:54:45.538: E/AndroidRuntime(334):  ... 21 more
09-04 22:54:45.538: E/AndroidRuntime(334): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.View.<init>(View.java:1951)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.View.<init>(View.java:1899)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.view.ViewGroup.<init>(ViewGroup.java:286)
09-04 22:54:45.538: E/AndroidRuntime(334):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
09-04 22:54:45.538: E/AndroidRuntime(334):  ... 24 more
09-04 22:55:01.926: I/Process(334): Sending signal. PID: 334 SIG: 9
4

1 に答える 1