我正在尝试官方开发人员网站上的 TabLayout 教程。我没有复制粘贴它,也没有对其中的拼写错误进行一些细微的更改和更正。
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");
}
}
作为第一步并确保代码正确,我想显示一个选项卡。
我将 FamilyLayout 活动添加到 AndroidManifest.xml 文件中,并在此处进行了建议的更改。Android TabHost 示例的问题 https://stackoverflow.com/questions/2209406/issues-with-android-tabhost-example
但应用程序在模拟器中运行时不断崩溃。任何帮助将非常感激。
[解决方案:]我使用了高分辨率和大小(3.5mb)的.jpeg,这是造成麻烦的原因。我将其更改为较低分辨率、尺寸的图片,并且没有遇到任何问题。我通过反复试验发现,超过 1600*900 的图像会使应用程序崩溃。虽然不是准确的统计数据,但可能会有所帮助。
我使用了高分辨率和大小(3.5mb)的.jpeg,这是造成麻烦的原因。我将其更改为较低分辨率、尺寸的图片,并且没有遇到任何问题。我通过反复试验发现,超过 1600*900 的图像会使应用程序崩溃。虽然不是准确的统计数据,但可能会有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)