无法在我的模拟器中打开按钮

时间:2016-06-21 08:16:12

标签: android

我有14个按钮,其中一个没有打开。它曾经打开,但现在它给了我一个错误,并在我点击它时关闭应用程序。我知道必须有一些我编码错误的东西。我正在看LogCat,但我无法从中获取任何东西。

这是我的代码:

<LinearLayout 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:orientation="vertical"
    tools:context="com.example.rodekruis.Bezoek"
    android:background="@drawable/rkzafbeelding"> 


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:src="@drawable/rkz_logo"
        android:layout_gravity="left" 
        android:layout_marginLeft="1dp"/>

     <ImageView
        android:id="@+id/imageButton1"
        android:layout_width="40dp"
        android:layout_height="50dp"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="10dp"
        android:layout_gravity="right" 
        android:src="@drawable/informatiebutton" />
 </FrameLayout>



    <TextView
        android:id="@+id/textView1"
        android:layout_width="244dp"
        android:layout_height="280dp"
        android:layout_gravity="center"
         android:text="@string/title_activity_bezoek"
        android:layout_marginTop="30dp"
        android:textAppearance="?android:attr/textAppearanceSmall"
         android:textColor="@color/black"
    />



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"/>
        <TextView
            android:id="@+id/textView2"
            android:layout_width="244dp"
            android:layout_height="95dp"
            android:layout_gravity="center"
            android:text="Klik hier voor de uitgebreide bezoektijden."
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button11"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginRight="5dp"
            android:layout_weight="1"
            android:text="Facebook" />

        <Button
            android:id="@+id/button12"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_weight="1"
            android:text="Youtube" />

        <Button
            android:id="@+id/button13"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignLeft="@+id/button5"
            android:layout_below="@+id/button8"
            android:layout_marginLeft="5dp"
            android:layout_weight="1"
            android:text="Twitter" />

        <Button
            android:id="@+id/button14"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignLeft="@+id/button5"
            android:layout_below="@+id/button8"
            android:layout_marginLeft="5dp"
            android:layout_weight="1"
            android:text="LinkedIn" />

    </LinearLayout>
        </LinearLayout>

这是我的LogCat:

06-21 06:50:45.595: D/dalvikvm(316): GC_EXTERNAL_ALLOC freed 80K, 51% free 2664K/5379K, external 1625K/2137K, paused 104ms
06-21 06:50:47.015: D/dalvikvm(316): GC_EXTERNAL_ALLOC freed 4K, 51% free 2686K/5379K, external 15420K/15441K, paused 40ms
06-21 06:50:50.015: D/dalvikvm(316): GC_EXTERNAL_ALLOC freed 11K, 50% free 2716K/5379K, external 15712K/17696K, paused 90ms
06-21 06:50:50.045: E/dalvikvm-heap(316): 12050168-byte external allocation too large for this process.
06-21 06:50:50.085: E/GraphicsJNI(316): VM won't let us allocate 12050168 bytes
06-21 06:50:50.085: D/dalvikvm(316): GC_FOR_MALLOC freed <1K, 50% free 2715K/5379K, external 15712K/17696K, paused 26ms
06-21 06:50:50.085: D/skia(316): --- decoder->decode returned false
06-21 06:50:50.085: D/AndroidRuntime(316): Shutting down VM
06-21 06:50:50.085: W/dalvikvm(316): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-21 06:50:50.125: E/AndroidRuntime(316): FATAL EXCEPTION: main
06-21 06:50:50.125: E/AndroidRuntime(316): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rodekruis/com.example.rodekruis.BezoekActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.os.Looper.loop(Looper.java:123)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-21 06:50:50.125: E/AndroidRuntime(316):  at java.lang.reflect.Method.invokeNative(Native Method)
06-21 06:50:50.125: E/AndroidRuntime(316):  at java.lang.reflect.Method.invoke(Method.java:507)
06-21 06:50:50.125: E/AndroidRuntime(316):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-21 06:50:50.125: E/AndroidRuntime(316):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-21 06:50:50.125: E/AndroidRuntime(316):  at dalvik.system.NativeStart.main(Native Method)
06-21 06:50:50.125: E/AndroidRuntime(316): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
06-21 06:50:50.125: E/AndroidRuntime(316):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-21 06:50:50.125: E/AndroidRuntime(316):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.Activity.setContentView(Activity.java:1657)
06-21 06:50:50.125: E/AndroidRuntime(316):  at com.example.rodekruis.BezoekActivity.onCreate(BezoekActivity.java:25)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-21 06:50:50.125: E/AndroidRuntime(316):  ... 11 more
06-21 06:50:50.125: E/AndroidRuntime(316): Caused by: java.lang.reflect.InvocationTargetException
06-21 06:50:50.125: E/AndroidRuntime(316):  at java.lang.reflect.Constructor.constructNative(Native Method)
06-21 06:50:50.125: E/AndroidRuntime(316):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
06-21 06:50:50.125: E/AndroidRuntime(316):  ... 21 more
06-21 06:50:50.125: E/AndroidRuntime(316): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.View.<init>(View.java:1951)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.View.<init>(View.java:1899)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.view.ViewGroup.<init>(ViewGroup.java:286)
06-21 06:50:50.125: E/AndroidRuntime(316):  at android.widget.LinearLayout.<init>(LinearLayout.java:120)
06-21 06:50:50.125: E/AndroidRuntime(316):  ... 24 more
06-21 06:50:52.845: I/Process(316): Sending signal. PID: 316 SIG: 9

感谢每一位帮助。

2 个答案:

答案 0 :(得分:1)

LinearLayout android:background="@drawable/rkzafbeelding"导致错误。并且还会出现OutOfMemory错误,确保Image大小不大。为了更好的性能,请使用Manifest.xml文件中的代码。

<application
         android:theme="@android:style/Theme.NoTitleBar"
        android:allowBackup="true"
        android:largeHeap="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
       >

答案 1 :(得分:0)

我没有看到任何点击功能,你究竟是什么意思'打开'?

android:onClick="OtherActivity"