如何在android中交换标签位置 我在Android中使用了嵌套标签,我的要求是选择的标签必须在中间。我试图解决这个问题,但是没有找到任何解决方案。
有人能告诉我解决办法吗 以下代码用于在我的如何在android中交换标签位置 我在Android中使用了嵌套标签,我的要求是选择的标签必须在中间。我试图解决这个问题,但是没有找到任何解决方案。,android,tabs,tabwidget,Android,Tabs,Tabwidget,有人能告诉我解决办法吗 以下代码用于在我的活动中排列选项卡 for (int i = 0; i < activitis.length; i++) { position = i; intent1 = new Intent().setClass(this, Tab_team.class); intent1.putExtra("tabactivity", activitis[i]); spec = tabHost.newTabSpec(activitis[i]).setIndicato
活动中排列选项卡
for (int i = 0; i < activitis.length; i++)
{
position = i;
intent1 = new Intent().setClass(this, Tab_team.class);
intent1.putExtra("tabactivity", activitis[i]);
spec = tabHost.newTabSpec(activitis[i]).setIndicator(activitis[i],
res.getDrawable(images[i])).setContent(intent1);
tabHost.addTab(spec);
}
for(int i=0;i
据我所知,您希望单击的选项卡按钮成为中心选项卡按钮
处理这个问题的一种方法是使用按钮来处理选项卡之间的切换。为此,请将xml文件修改为
<FrameLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="64dip">
<Button android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/artist_id"
android:onClick="tabHandler"/>
<Button android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/album_id"
android:onClick="tabHandler"/>
<Button android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1.0"
android:background="@drawable/ic_tab_artists"
android:id="@+id/song_id"
android:onClick="tabHandler"/>
</LinearLayout>
</FrameLayout>
在这里,我使用选项卡主机切换选项卡。在相同的方法中,您可以编写代码来删除单击的按钮,并将其重新插入到outerlayout的中间位置。
可能会有更简单的解决方案,但您需要进行反复试验。但这是处理需求的一种方法
public void tabHandler(View target){
tab1Btn.setSelected(false);
tab2Btn.setSelected(false);
tab3Btn.setSelected(false);
target.setSelected(true);
if(target.getId() == R.id.artist_id){
tabHost.setCurrentTab(0);
} else if(target.getId() == R.id.album_id){
tabHost.setCurrentTab(1);
} else if(target.getId() == R.id.song_id){
tabHost.setCurrentTab(2);
}
}