安卓:TabLayout不工作 [英] Android: TabLayout not working

查看:121
本文介绍了安卓:TabLayout不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从官方网站的开发人员尝试TabLayout教程。我没有复制粘贴这样而在啧啧一些小的改动和更正拼写错误。

I was trying the TabLayout Tutorial from official developers site. I didnt copy paste it as such and some minor changes and corrections to typos in the tut.

package com.org.example;

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

public class HalloTabLayout extends TabActivity {



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

        Intent intent;
     TabHost tabhost = getTabHost();
     TabHost.TabSpec tabspec;
     Resources res = getResources();

        //For the Family Tab

        //Intent

        intent = new Intent().setClass(this, FamilyLayout.class);

        //Setting the tab

        tabspec = tabhost.newTabSpec("family").setIndicator("Family", res.getDrawable(R.drawable.tab_spec)).setContent(intent);

        tabhost.addTab(tabspec); 

      //Default tab to display

        tabhost.setCurrentTabByTag("family");
    }

}

作为第一步,确保code是正确的,我想有显示的单个标签。

As a first step and make sure the code is right, I wanted to have a Single tab displayed.

我添加了FamilyLayout活动AndroidManifest.xml文件,并也取得了这里建议的更改。 <一href=\"http://stackoverflow.com/questions/2209406/issues-with-android-tabhost-example\">http://stackoverflow.com/questions/2209406/issues-with-android-tabhost-example

I added the FamilyLayout activity to AndroidManifest.xml file and also made changes suggested in here. http://stackoverflow.com/questions/2209406/issues-with-android-tabhost-example

但应用程序保持在模拟器上崩溃的运行时间。任何帮助将是非常美联社preciated。

But the application keeps crashing on run time in the emulator. Any help would be much appreciated.

[解决方法:] 我用很高的分辨率和尺寸(3.5MB),这是麻烦事业的.JPEG。我把它改为一个较低的分辨率,图片大小和它的工作没有烦恼。我通过试验和错误是超过1600×900的图像会使应用程序崩溃发现了。没有一个确切的统计,但它可能会有所帮助。

[Solution:] I used a .jpeg of high resolution and size(3.5mb) which was cause of trouble. I changed it into a lower resolution, size pic and it worked without troubles. I found out via trial and error that images beyond 1600*900 will make apps crash. Not an exact statistic, but it may help.

推荐答案

我用很高的分辨率和尺寸(3.5MB),这是麻烦事业的.JPEG。我把它改为一个较低的分辨率,图片大小和它的工作没有烦恼。我通过试验和错误是超过1600×900的图像会使应用程序崩溃发现了。没有一个确切的统计,但它可能会有所帮助。

I used a .jpeg of high resolution and size(3.5mb) which was cause of trouble. I changed it into a lower resolution, size pic and it worked without troubles. I found out via trial and error that images beyond 1600*900 will make apps crash. Not an exact statistic, but it may help.

这篇关于安卓:TabLayout不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆