小编spa*_*rky的帖子

Honeycomb和TabHost规格

我对Honeycomb的向后兼容性有疑问.我有一个支持2.1或更高版本的应用程序,似乎主要在Honeycomb上工作,除非他们启动TabActivity.

特别是,当我向TabHost添加标签时,我得到以下异常

android.content.res.Resources $ NotFoundException:资源ID#0x0

在查看抛出此异常的代码时,我发现它是带有标签和图标的选项卡规范.在代码内部,LabelAndIconIndicatorStrategy尝试对布局文件R.layout.tab_indicator进行充气,该文件似乎不可用.

    TabHost.TabSpec spec; // Resusable TabSpec for each tab
    Intent intent; // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(_gameActivity, ScoreGameActivity.class);
    intent.putExtra(GameChangerConstants.STREAM_ID, _stream.pk().toString());

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = _gameTabHost.newTabSpec("score_game").setIndicator("Score", res.getDrawable(R.drawable.icon_field_gloss)).setContent(intent);
    _gameTabHost.addTab(spec);
Run Code Online (Sandbox Code Playgroud)

有没有为蜂窝创建标签的新方法,我不知道?我已经倾倒了文档,但没有看到任何表明我所做的事情的问题.

在此之前,我想避免使用片段,直到我们可以对UI小部件进行更全面的重构,并且我希望更好地理解这个问题.

android android-tabhost android-3.0-honeycomb

4
推荐指数
1
解决办法
3041
查看次数