【发布时间】:2015-02-17 21:03:25
【问题描述】:
我有一个包含项目的 TabHost,我希望它们仅在单击时突出显示。
我以前有过它,但我在 ListViews 本身上没有改变任何东西,但在 TabHost 上(我认为这应该没关系..)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="at.htl3r.appmosphere.MainActivity$PlaceholderFragment" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<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" >
<ListView
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<ListView
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<ListView
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<ListView
android:id="@+id/tab4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
我阅读了一些如何禁用它的帖子,但 I don't want to disable it complete 因为我将处理点击操作
我尝试添加choiceMode="none" 和selector
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/darkgreen_light" android:state_pressed="true"/>
<item android:drawable="@android:color/transparent" android:state_activated="true"/>
<item android:drawable="@android:color/transparent" android:state_checked="true"/>
<item android:drawable="@android:color/transparent" android:state_selected="true"/>
<item android:drawable="@android:color/transparent"/>
</selector>
更新
更好的选择:ViewPagerIndicator
【问题讨论】:
标签: android listview android-fragments android-tabhost