导航栏在手机上工作但不在平板电脑上?

时间:2013-03-17 13:41:46

标签: java android navigation android-tabhost

对,我有一个导航菜单系统,但它可以在我的Galaxy s2上工作,但当我把它放在我的姐妹平板电脑上它不会工作:(我得到这个错误,如下所示,但我现在没有错,所以如果有人可能会有所帮助!

当点击顶部的栏时,代码显然将用户转移到另一个页面,我看了彻底的代码,我不知道如何解决它,所以如果有人可以帮助/指出甚至修复它我永远爱你!

主要xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>

导航菜单代码

package biz.themeparkguide.ridecount;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class CoasterActivity extends TabActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = getTabHost();

        // Tab for home
        TabSpec homeSpec = tabHost.newTabSpec("Home");
        // setting Title and Icon for the Tab
        homeSpec.setIndicator("Home", getResources().getDrawable(R.drawable.icon_home_tab));
        Intent homeIntent = new Intent(this, HomeActivity.class);
        homeSpec.setContent(homeIntent);

        // Tab for Counter 1
        TabSpec counter1 = tabHost.newTabSpec("Thorpe Park");
        counter1.setIndicator("Thorpe Park", getResources().getDrawable(R.drawable.tplogo));
        Intent counter1Intent = new Intent(this, CounterOneActivity.class);
        counter1.setContent(counter1Intent);

        // Tab for Counter 2
        TabSpec counter2 = tabHost.newTabSpec("2nd Page");
        counter2.setIndicator("Alton", getResources().getDrawable(R.drawable.altontowerslogo));
        Intent counter2Intent = new Intent(this, CounterTwoActivity.class);
        counter2.setContent(counter2Intent);

     // Tab for Counter 3

        TabSpec counter3 = tabHost.newTabSpec("3rd Page");
        counter3.setIndicator("Chessington", getResources().getDrawable(R.drawable.chessingtonlogo));
        Intent counter3Intent = new Intent(this, CounterThreeActivity.class);
        counter3.setContent(counter3Intent);


        // Adding all TabSpec to TabHost
        tabHost.addTab(homeSpec); // Adding home tab
        tabHost.addTab(counter1); // Adding counter 1 tab
         tabHost.addTab(counter2); // Adding counter 2 tab
        tabHost.addTab(counter3); // Adding counter 3 tab



        //add animation on tab change
        AnimatedTabHostListener listener = new AnimatedTabHostListener(tabHost);
        tabHost.setOnTabChangedListener(listener);
    }
}

错误:

03-17 13:36:02.646: E/AndroidRuntime(4104): FATAL EXCEPTION: main
03-17 13:36:02.646: E/AndroidRuntime(4104): java.lang.RuntimeException: Unable to start activity ComponentInfo{biz.themeparkguide.ridecount/biz.themeparkguide.ridecount.CounterOneActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class <unknown>
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1938)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:705)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.widget.TabHost.setCurrentTab(TabHost.java:369)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:560)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.View.performClick(View.java:4222)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.View$PerformClick.run(View.java:17273)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.os.Handler.handleCallback(Handler.java:615)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.os.Looper.loop(Looper.java:137)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.ActivityThread.main(ActivityThread.java:4895)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at java.lang.reflect.Method.invokeNative(Native Method)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at java.lang.reflect.Method.invoke(Method.java:511)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at dalvik.system.NativeStart.main(Native Method)
03-17 13:36:02.646: E/AndroidRuntime(4104): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class <unknown>
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.Activity.setContentView(Activity.java:1912)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at biz.themeparkguide.ridecount.CounterOneActivity.onCreate(CounterOneActivity.java:26)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.Activity.performCreate(Activity.java:5163)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
03-17 13:36:02.646: E/AndroidRuntime(4104):     ... 18 more
03-17 13:36:02.646: E/AndroidRuntime(4104): Caused by: java.lang.reflect.InvocationTargetException
03-17 13:36:02.646: E/AndroidRuntime(4104):     at java.lang.reflect.Constructor.constructNative(Native Method)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-17 13:36:02.646: E/AndroidRuntime(4104):     ... 33 more
03-17 13:36:02.646: E/AndroidRuntime(4104): Caused by: java.lang.OutOfMemoryError
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:592)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.content.res.Resources.loadDrawable(Resources.java:1963)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.View.<init>(View.java:3443)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.View.<init>(View.java:3376)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.view.ViewGroup.<init>(ViewGroup.java:426)
03-17 13:36:02.646: E/AndroidRuntime(4104):     at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
03-17 13:36:02.646: E/AndroidRuntime(4104):     ... 36 more

0 个答案:

没有答案