1

設定アクティビティで HoloEverywhere を使用しようとすると、logcat で次のエラーが発生します。

10-26 09:56:59.653: E/AndroidRuntime(3552): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.LayoutInflater.onCreateView(LayoutInflater.java:195)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.preference.Preference.onCreateView(Preference.java:514)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.preference.Preference.getView(Preference.java:404)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:158)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.AbsListView.obtainView(AbsListView.java:1430)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.ListView.makeAndAddView(ListView.java:1745)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.ListView.fillDown(ListView.java:670)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.ListView.fillFromTop(ListView.java:727)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.ListView.layoutChildren(ListView.java:1598)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.AbsListView.onLayout(AbsListView.java:1260)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1243)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1049)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.layout(View.java:7175)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.os.Looper.loop(Looper.java:130)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.app.ActivityThread.main(ActivityThread.java:3683)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at java.lang.reflect.Method.invokeNative(Native Method)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at java.lang.reflect.Method.invoke(Method.java:507)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at dalvik.system.NativeStart.main(Native Method)
10-26 09:56:59.653: E/AndroidRuntime(3552): Caused by: java.lang.reflect.InvocationTargetException
10-26 09:56:59.653: E/AndroidRuntime(3552):     at java.lang.reflect.Constructor.constructNative(Native Method)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-26 09:56:59.653: E/AndroidRuntime(3552):     ... 46 more
10-26 09:56:59.653: E/AndroidRuntime(3552): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.<init>(View.java:2108)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.View.<init>(View.java:1899)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.view.ViewGroup.<init>(ViewGroup.java:286)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at android.widget.LinearLayout.<init>(LinearLayout.java:120)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.widget.LinearLayout.<init>(LinearLayout.java:37)
10-26 09:56:59.653: E/AndroidRuntime(3552):     at com.WazaBe.HoloEverywhere.widget.LinearLayout.<init>(LinearLayout.java:33)
10-26 09:56:59.653: E/AndroidRuntime(3552):     ... 49 more

オーバーフロー メニュー項目から settingsActivity を開始します。HoloEverywhere-Demo にオーバーフロー メニューを追加し、選択したときにアクティビティを開始すると、それが機能します。これが私の設定アクティビティです:

public class SettingsActivity extends com.WazaBe.HoloEverywhere.sherlock.SPreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settings);
    }   
    @Override
    public void onStart() {
        super.onStart();
        initActionBar();
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    private void initActionBar() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar_gradient));
        actionBar.setTitle(R.string.settings);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);
    }
}

このアクティビティをデモで問題なく使用できるのに、アプリケーションに追加すると投稿したエラーが表示される理由はありますか?

4

1 に答える 1

3

あなたの settings.xml はホロ属性を使用していますか? xmlns を holo に、すべての android: を holo: に変更する必要があります。

このような:

<PreferenceScreen xmlns:holo="http://schemas.android.com/apk/res-auto" >

<PreferenceCategory holo:title="title" >
    <Preference
        holo:key="key"
        holo:summary="summary"
        holo:title="title" />
</PreferenceCategory>

<Preference
    holo:key="key"
    holo:title="title"
    holo:selectable="true" />
</PreferenceScreen>
于 2012-11-13T13:11:53.453 に答える