android – 为什么eclipse突出显示R.id.tabhost?

android – 为什么eclipse突出显示R.id.tabhost?,第1张

概述我正在尝试在我的应用程序中实现选项卡,但是id tabhost正在突出显示,为什么? 我看的每个教程都有TabHost tabs =(TabHost)findViewById(R.id.tabhost),每次我都包含这行id tabhost是hightlighted,错误:tabhost无法解析或不是字段. recipe_list.java: TabHost tabs=(TabHost)findV 我正在尝试在我的应用程序中实现选项卡,但是ID tabhost正在突出显示,为什么?

我看的每个教程都有TabHost tabs =(TabHost)findVIEwByID(R.ID.tabhost),每次我都包含这行ID tabhost是hightlighted,错误:tabhost无法解析或不是字段.

recipe_List.java:

TabHost tabs=(TabHost)findVIEwByID(R.ID.tabhost);tabs.setup();TabHost.TabSpec spec=tabs.newTabSpec("tag1");spec.setContent(R.ID.tab1);spec.setIndicator("Clock");tabs.addTab(spec);spec=tabs.newTabSpec("tag2");spec.setContent(R.ID.tab2);spec.setIndicator("button");tabs.addTab(spec);

recipe_List.xml,我在每个标签中都有列表视图:

<TabHost    androID:ID="@androID:ID/tabhost"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent" >    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:orIEntation="vertical" >        <TabWidget            androID:ID="@androID:ID/tabs"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content" >        </TabWidget>        <FrameLayout            androID:ID="@androID:ID/tabcontent"            androID:layout_wIDth="match_parent"            androID:layout_height="match_parent" >            <linearLayout                androID:ID="@+ID/tab1"                androID:layout_wIDth="match_parent"                androID:layout_height="match_parent" >                <ListVIEw                    androID:ID="@+ID/ListVIEw1"                    androID:layout_wIDth="match_parent"                    androID:layout_height="fill_parent"                    androID:layout_weight="1" >                </ListVIEw>            </linearLayout>            <linearLayout                androID:ID="@+ID/tab2"                androID:layout_wIDth="match_parent"                androID:layout_height="match_parent" >                <ListVIEw                    androID:ID="@+ID/ListVIEw2"                    androID:layout_wIDth="match_parent"                    androID:layout_height="wrap_content"                    androID:layout_weight="1" >                </ListVIEw>            </linearLayout>            <linearLayout                androID:ID="@+ID/tab3"                androID:layout_wIDth="match_parent"                androID:layout_height="match_parent" >            </linearLayout>        </FrameLayout>    </linearLayout></TabHost>
解决方法
TabHost tabs=(TabHost)findVIEwByID(androID.R.ID.tabhost);

要么

TabHost tabs=getTabHost();
总结

以上是内存溢出为你收集整理的android – 为什么eclipse突出显示R.id.tabhost?全部内容,希望文章能够帮你解决android – 为什么eclipse突出显示R.id.tabhost?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1122904.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存