我想创建这种类型的自定义选项卡并在我的应用程序中实现..我想知道如何做到这一点..如果您有任何链接,那么请分享我...在此先感谢... 如何制作像这种类型的自定义标签?
0
A
回答
0
可能会有所帮助。或者你也可以为自己创建一个客户选项卡控件
1
我在2个月前得到了相同的要求....我搜索了这么多的例子,但我找不到正确的解决方案。
其实我设计的标签两种图像...相同的图像,但两种不同的分辨率
最后我设计像下面的XML ...工作得很好
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabHost
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1">
</FrameLayout>
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="55dp"
/>
</LinearLayout>
</TabHost>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<ImageView
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:background="@drawable/tab_mybars_on"
/>
<ImageView
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:background="@drawable/tab_mybeers_on"
/>
<ImageView
android:id="@+id/tab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:background="@drawable/tab_events_on"
/>
<ImageView
android:id="@+id/tab4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:background="@drawable/tab_coupons_on"
/>
<ImageView
android:id="@+id/tab5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:background="@drawable/tab_brewedlife_on"
/>
</LinearLayout>
</RelativeLayout>
最后的代码选项卡活动:
public class DownTabActivity extends TabActivity implements OnClickListener
{
public static TabHost host;
TabSpec spec;
static int loadingcheck=0;
public static String tabTag;
ImageView tab[]=new ImageView[5];
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
spec= null;
host= getTabHost();
host.setFocusable(false);
// host.getTabWidget().setDividerDrawable(R.drawable.tabbar_divider);
host.addTab(createTab("My Bars","MyBars",R.drawable.tab_mybars,MyBarsTabActivity.class));
host.addTab(createTab("My Beers","MyBeers",R.drawable.tab_mybeers, MyBeersTabActivity.class));
host.addTab(createTab("Events","Events",R.drawable.tab_myevents, MyEventsTabActivity.class));
host.addTab(createTab("Coupons","Coupons",R.drawable.tab_coupons, CouponsTabActivity.class));
host.addTab(createTab("Brewed Life","BrewedLife",R.drawable.tab_brewedlife, BrewedLifeTabActivity.class));
host.setOnClickListener(this);
tab[0]=(ImageView)findViewById(R.id.tab1);
tab[1]=(ImageView)findViewById(R.id.tab2);
tab[2]=(ImageView)findViewById(R.id.tab3);
tab[3]=(ImageView)findViewById(R.id.tab4);
tab[4]=(ImageView)findViewById(R.id.tab5);
tabTag = host.getCurrentTabTag();
Log.e("tab",tabTag);
tab[host.getCurrentTab()].setVisibility(View.VISIBLE);
host.setOnTabChangedListener(new TabHost.OnTabChangeListener()
{
public void onTabChanged(String arg0)
{
Log.e("tab argument is", arg0);
for(int i=0;i<5;i++){
if(i==host.getCurrentTab()) tab[i].setVisibility(View.VISIBLE);
else tab[i].setVisibility(View.INVISIBLE);
}
}
});
}
private TabSpec createTab(final String title, final String tag,final int drawable,final Class<?> intentClass)
{
final Intent intent = new Intent().setClass(this, intentClass);
final View tab = LayoutInflater.from(getTabHost().getContext()).inflate(R.layout.tab_indicator, null);
((TextView)tab.findViewById(R.id.tab_text)).setText("");
((ImageView)tab.findViewById(R.id.tab_icon)).setBackgroundResource(drawable);
return getTabHost().newTabSpec(tag).setIndicator(tab).setContent(intent);
}
public void onClick(View v)
{
Log.v("on click Down tab", "on click Down tab");
}
}
+0
接受这个答案,如果它工作正常 – Santosh 2013-02-15 04:45:45
相关问题
- 1. 如何制作标识为自定义UTI类型的文件?
- 2. 自定义CKAN资源类型标签
- 3. Umbraco自定义数据类型 - 如何隐藏标签?
- 4. 如何制作使用其他JSP标签的自定义JSP标签?
- 5. 如何制作这样的自定义标记? osmdroid
- 6. 如何制作自定义fontawsome图标?
- 7. 如何为我的自定义类型制作模板?
- 8. Visual Studio:如何找出这种类型的定义?
- 9. XSD - 限制型三种自定义类型
- 10. 我该如何制作这种类型的iOS动画?
- 11. 如何制作这种类型的壁纸?
- 12. 我如何在黑莓中制作这种类型的列表?
- 13. 这种类型的定义对一个&&有什么作用
- 14. 在WordPress中添加自定义帖子类型的自定义标签
- 15. 定义自定义标签
- 16. 这种类型的静态XAML绑定是如何工作的?
- 17. 自定义ValidationAttribute多种数据类型
- 18. 如何制作按钮按钮类型(自定义键盘)
- 19. Bootstrap标签自动清除自定义值后类型
- 20. 这个自定义标签是如何配置的?
- 21. ColdFusion的使用自定义标签中自定义标签
- 22. django头像自定义模板标签
- 23. 如何使用google-gson将这种自定义类型序列化为json?
- 24. 如何制作类似MIUI的标签
- 25. 如何自定义复杂类型转换为另一种自定义的复杂类型
- 26. 自定义帖子类型中的自定义分类标准的条件标签
- 27. 如何使图像和标签自定义正确的UIBarButtonItem?
- 28. 我如何列出具有某种类型的自定义帖子类型
- 29. WordPress的得到自定义帖子类型标签名称
- 30. 属于自定义后类型的WordPress显示标签
兄弟我想使这个标签在Anroid的 – 2013-02-14 13:21:42
@MehulRanpara hahahahahaha – 2013-03-27 18:30:51