0

これはかなり頻繁に尋ねられていることを知っていますが、これはまったく異なります。ログ ファイルは、原因について言及することなく、上記の例外を数回投稿するだけです。ログファイルは以下の通り


01-31 09:53:10.305: E/AndroidRuntime(452): FATAL EXCEPTION: main
01-31 09:53:10.305: E/AndroidRuntime(452): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: android.view.InflateException: Binary XML file line #37: Error inflating class <unknown>
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.os.Looper.loop(Looper.java:123)
01-31 09:53:10.305: E/AndroidRuntime(452):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-31 09:53:10.305: E/AndroidRuntime(452):  at java.lang.reflect.Method.invokeNative(Native Method)
01-31 09:53:10.305: E/AndroidRuntime(452):  at java.lang.reflect.Method.invoke(Method.java:507)
01-31 09:53:10.305: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-31 09:53:10.305: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-31 09:53:10.305: E/AndroidRuntime(452):  at dalvik.system.NativeStart.main(Native Method)
01-31 09:53:10.305: E/AndroidRuntime(452): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.iolcalci.Second}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iolcalci/com.example.i

Javaファイルは次のとおりです

package com.example.iolcalci;


import com.itab.graphics.TabBitmap;

@SuppressWarnings("deprecation")
public class Second extends ActivityGroup {
    private TabHost mTabHost;
    private static final String TAG_1 = "tab1";
    private static final String TAG_2 = "tab2";
    private static final String TAG_3 = "tab3";
    private static final String TAG_4 = "tab4";

    @SuppressWarnings("deprecation")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
        setTabs();
    }
    private void setTabs() {
        mTabHost = (TabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup(getLocalActivityManager());

        addTab("SRK/T", TAG_1, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(this, Second.class));
        addTab("SRK II", TAG_2, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(this, Srk2_x.class));
        addTab("BINKHORST", TAG_3, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(this, Binkhorst_x.class));
        addTab("HOLLADAY", TAG_4, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(this, Holladay_x.class));
    }
    private Drawable createTabDrawable(int resId) {
        Resources res = getResources();
        StateListDrawable states = new StateListDrawable();

        final Options options = new Options();
        options.inPreferredConfig = Config.ARGB_8888;

        Bitmap icon = BitmapFactory.decodeResource(res, resId, options);

        Bitmap unselected = TabBitmap.createUnselectedBitmap(res, icon);
        Bitmap selected = TabBitmap.createSelectedBitmap(res, icon);

        icon.recycle();

        states.addState(new int[] { android.R.attr.state_selected }, new BitmapDrawable(res, selected));
        states.addState(new int[] { android.R.attr.state_enabled }, new BitmapDrawable(res, unselected));

        return states;
    }
    private View createTabIndicator(String label, Drawable drawable) {
        View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, mTabHost.getTabWidget(), false);

        TextView txtTitle = (TextView) tabIndicator.findViewById(R.id.text_view_tab_title);
        txtTitle.setText(label);
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) txtTitle.getLayoutParams();
        txtTitle.setLayoutParams(params);

        ImageView imgIcon = (ImageView) tabIndicator.findViewById(R.id.image_view_tab_icon);
        imgIcon.setImageDrawable(drawable);

        return tabIndicator;
    }

    private void addTab(String label, String tag, Drawable drawable, Intent intent) {
        TabHost.TabSpec spec = mTabHost.newTabSpec(tag);
        spec.setIndicator(createTabIndicator(label, drawable));
        spec.setContent(intent);
        mTabHost.addTab(spec);
    }


}

XML

 <?xml version="1.0" encoding="utf-8"?>


<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:ignore="HardcodedText" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:background="@color/Black" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/tab_height" >
            </TabWidget>

            <TextView
                android:id="@+id/text_view_srkt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textSize="10sp" />

            <TextView
                android:id="@+id/text_view_srk2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textSize="10sp" />

            <TextView
                android:id="@+id/text_view_holl"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textSize="10sp" />

            <TextView
                android:id="@+id/text_view_bink"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textSize="10sp" />
        </FrameLayout>
    </LinearLayout>

</TabHost>

助けてください。問題がわかりにくかった

4

1 に答える 1

0

メソッドはビットマップに関連付けられたネイティブオブジェクトを解放し、ピクセルデータへの参照をクリアするicon.recycle();ため、問題はこの行に起因すると思い ます。recycle()だからこのように使ってみてください

 states.addState(new int[] { android.R.attr.state_selected }, new BitmapDrawable(res, selected));
        states.addState(new int[] { android.R.attr.state_enabled }, new BitmapDrawable(res, unselected));
        icon.recycle();
于 2013-01-31T05:37:41.463 に答える