我从这里下载了用于 android 的凸起标签主机:
https://github.com/AdilSoomro/Raised-Center-Tab-in-Android
我写了这段代码:
public class TabMainActivity extends TabActivity {
TabHost tabHost;
private String name;
private String city;
private String country;
private String street;
private String id;
private String email;
private String password;
private String phone;
private String emailOwner;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_main);
Intent intent = getIntent();
name = intent.getExtras().getString("name");
password = intent.getExtras().getString("password");
email = intent.getExtras().getString("email");
id = intent.getExtras().getString("id");
phone = intent.getExtras().getString("phone");
emailOwner=intent.getExtras().getString("emailOwner");
tabHost = getTabHost();
setTabs();
}
private void setTabs()
{
addTab("Home", R.drawable.tab_home, ProfileActivity.class);
addTab("Search", R.drawable.tab_search, SaleMapActivity.class);
addTab("Fake", R.drawable.tab_search, GroupMapActivity.class);
addTab("Home", R.drawable.tab_home, DeliverMapActivity.class);
addTab("Search", R.drawable.tab_search, ProfileActivity.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
Intent intent = new Intent(this, c);
intent.putExtra("emailOwner", emailOwner);
intent.putExtra("phone", phone);
intent.putExtra("email",email );
intent.putExtra("password",password );
intent.putExtra("id",id );
intent.putExtra("name",name );
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
public void openCameraActivity(View b)
{
Intent i = new Intent(this, ProfileActivity.class);
i.putExtra("emailOwner", emailOwner);
i.putExtra("phone", phone);
i.putExtra("email",email );
i.putExtra("password",password );
i.putExtra("id",id );
i.putExtra("name",name );
startActivity(i);
}
}
每当我单击中心按钮(cumera 按钮)时,它都会打开配置文件活动,但是选项卡会消失..
我如何实现当单击居中按钮(相机按钮)时标签不会消失?
谢谢