Quote: 引用:我感觉你说的没有影响啊,那你可否这样:

private void setupViews() {

setContentView(R.layout.activity_main);

mDriverTextView = (TextView) View.inflate(this, R.layout.view_tab, null);

mDriverTextView.setBackgroundResource(R.drawable.button_driver_selector);

mOrderTextView = (TextView) View.inflate(this, R.layout.view_tab, null);

mOrderTextView.setBackgroundResource(R.drawable.button_order_selector);

mPriceTextView = (TextView) View.inflate(this, R.layout.view_tab, null);

mPriceTextView.setBackgroundResource(R.drawable.button_price_selector);

TabHost tabHost = getTabHost();

// 第一个tab

Intent driverIntent = new Intent(ChauffeurActivity.this, DriverActivity.class);

tabHost.addTab(tabHost.newTabSpec("0").setIndicator(mDriverTextView).setContent(driverIntent));

// 第二个tab

Intent orderIntent = new Intent(ChauffeurActivity.this, ProfileActivity.class);

tabHost.addTab(tabHost.newTabSpec("1").setIndicator(mOrderTextView).setContent(orderIntent));

// 第三个tab

Intent priceIntent = new Intent(ChauffeurActivity.this,PriceActivity.class);

tabHost.addTab(tabHost.newTabSpec("2").setIndicator(mPriceTextView).setContent(priceIntent));

// 设置监听器

tabHost.setOnTabChangedListener(this);

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐