私は Iphone のような TabBar を実装しようとしていて、ListView に情報を表示したいと思っていました。都市を選択した後、その都市に関連するものを含む別のリストを取得しますが、新しいビューを呼び出すと、TabBAr が失われ、 **次のビューに情報を表示するには、どのアクティビティが機能していてもTABBARは一番下にある必要があります**
最初のタブ (ホーム タブ) のスクリーン ショットを取得しました
都市を選択した場所で、TabBar が下にある状態で次の画面に移動し、次に次のビューに移動し、次の画面に移動し、最後のスクリーンショットまで画像を表示します。
しかし、Androidでどうすればいいのかわかりません。
[ホーム] タブにあるすべてのビューに TabBar を表示するにはどうすればよいですか?
これまでのところ、私はこのコードを持っています:
TabHostProvider.java
import android.app.Activity;
public abstract class TabHostProvider {
public Activity context;
public TabHostProvider(Activity context){
this.context = context;
}
public abstract TabView getTabHost(String category);
}
[Tab.java][2]
MyTabHostProvider.java
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
public class MyTabHostProvider extends TabHostProvider {
private Tab cityTab;
private Tab searchTab;
private Tab mapTab;
private Tab favouriteTab;
private Tab settingTab;
private TabView tabView;
private GradientDrawable gradientDrawable, transGradientDrawable;
public MyTabHostProvider(Activity context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public TabView getTabHost(String category) {
// TODO Auto-generated method stub
tabView = new TabView(context);
tabView.setOrientation(TabView.Orientation.BOTTOM);
tabView.setBackgroundID(R.drawable.tab_background_gradient);
gradientDrawable = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {0xFFB2DA1D, 0xFF85A315});
gradientDrawable.setCornerRadius(0f);
gradientDrawable.setDither(true);
transGradientDrawable = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {0x00000000, 0x00000000});
transGradientDrawable.setCornerRadius(0f);
transGradientDrawable.setDither(true);
cityTab = new Tab(context, category);
cityTab.setIcon(R.drawable.navbar_allnormal);
cityTab.setIconSelected(R.drawable.navbar_allselected);
cityTab.setBtnText("City");
cityTab.setBtnTextColor(Color.WHITE);
cityTab.setSelectedBtnTextColor(Color.BLACK);
cityTab.setBtnGradient(transGradientDrawable);
cityTab.setSelectedBtnGradient(gradientDrawable);
cityTab.setIntent(new Intent(context, CityActivity.class));
searchTab = new Tab(context, category);
searchTab.setIcon(R.drawable.navbar_picturenormal);
searchTab.setIconSelected(R.drawable.navbar_pictureselected);
searchTab.setBtnText("Search");
searchTab.setBtnTextColor(Color.WHITE);
searchTab.setSelectedBtnTextColor(Color.BLACK);
searchTab.setBtnGradient(transGradientDrawable);
searchTab.setSelectedBtnGradient(gradientDrawable);
searchTab.setIntent(new Intent(context, SearchActivity.class));
mapTab = new Tab(context, category);
mapTab.setIcon(R.drawable.navbar_filenormal);
mapTab.setIconSelected(R.drawable.navbar_fileselected);
mapTab.setBtnText("Map");
mapTab.setBtnTextColor(Color.WHITE);
mapTab.setSelectedBtnTextColor(Color.BLACK);
mapTab.setBtnGradient(transGradientDrawable);
mapTab.setSelectedBtnGradient(gradientDrawable);
mapTab.setIntent(new Intent(context, MapFragment.class));
favouriteTab = new Tab(context, category);
favouriteTab.setIcon(R.drawable.navbar_videonormal);
favouriteTab.setIconSelected(R.drawable.navbar_videoselected);
favouriteTab.setBtnText("Favourites");
favouriteTab.setBtnTextColor(Color.WHITE);
favouriteTab.setSelectedBtnTextColor(Color.BLACK);
favouriteTab.setBtnGradient(transGradientDrawable);
favouriteTab.setSelectedBtnGradient(gradientDrawable);
favouriteTab.setIntent(new Intent(context, FavouritesActivity.class));
settingTab = new Tab(context, category);
settingTab.setIcon(R.drawable.navbar_morenormal);
settingTab.setIconSelected(R.drawable.navbar_moreselected);
settingTab.setBtnText("Settings");
settingTab.setBtnTextColor(Color.WHITE);
settingTab.setSelectedBtnTextColor(Color.BLACK);
settingTab.setBtnGradient(transGradientDrawable);
settingTab.setSelectedBtnGradient(gradientDrawable);
settingTab.setIntent(new Intent(context, SettingsActivity.class));
tabView.addTab(cityTab);
tabView.addTab(searchTab);
tabView.addTab(mapTab);
tabView.addTab(favouriteTab);
tabView.addTab(settingTab);
return tabView;
}
}
CityActivity.java
public class CityActivity extends Activity {
private final String TAG = CityActivity.class.getSimpleName();
private ListView moreList = null;
private final String[] moreItems = { "Srinagar", "Gulmarg", "Pehlgam", "Jammu", "Leh",
"Patnitop"};
private TextView tv;
private Button action_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHostProvider tabProvider = new MyTabHostProvider(CityActivity.this);
TabView tabView = tabProvider.getTabHost("City");
tabView.setCurrentView(R.layout.city);
setContentView(tabView.render(0));
moreList = (ListView) findViewById(R.id.moreactivity_list);
moreList.setAdapter(new MoreCityAdapter(CityActivity.this, moreItems));
moreList.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
final String activity = moreList.getAdapter().getItem(position).toString().trim();
Log.d(TAG, "Clicked Item: " + activity);
tv = (TextView)findViewById(R.id.tv_header_title);
tv.setText(activity);
Intent intent = new Intent(CityActivity.this, Second.class);
startActivity(intent);
}
});
}
Second.java
public class Second extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.city_second);
Here i need to show the Tab bar with my List View
How should i get the Tab Bar here and on my following Third,Fourth & Fifth Activity
}
}
[MoreCityAdapter.java][3]