我想創建這種類型的自定義選項卡並在我的應用程序中實現..我想知道如何做到這一點..如果您有任何鏈接,那麼請分享我...在此先感謝... 如何製作像這種類型的自定義標籤?
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