Hallo Ich suche ein gutes Beispiel für die Erstellung meiner eigenen Tab-Leiste (am unteren Rand) mit Fragmenten.Erstellen von Tab-Leiste mit Fragmenten aus Support-Paket
Früher hatte ich dies mit Aktivitätsgruppen geschrieben, aber von Android 3. * es ist veraltet und ich muss dies mit Fragmenten tun.
Hier ist der Code, den ich meine benutzerdefinierte Tab Bar geschrieben hatte, zu schaffen:
private void setTabs()
{
//Implementing strings
String publication = String.format("First");
String shop = String.format("Second");
//Adding tabs to TabActivity
//addTab(publication, R.drawable.ic_launcher, DisplayTestActivity.class);
//addTab(shop, R.drawable.ic_launcher, DisplayPushedTestActivity.class);
}
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
}
/**
*
* @param labelId, tab name
* @param drawableId, tab icon image
* @param c, responsible class
*/
/*
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost(); // The activity TabHost
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
System.out.println(tabIndicator);
TextView title = (TextView) tabIndicator.findViewById(R.id.tab_bar_title);
System.out.println(labelId);
System.out.println(title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.tab_bar_icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
Vielleicht ein paar Informationen darüber könnte jemand teilen.
Danke.
Ich benutze bereits Action Bar Sherlock und möchte auch Tab-Leiste – Streetboy