标签布局不显示,因为我想要
问题描述:
我使用自定义背景为我的标签布局,但它显示不同的东西。作为 标签布局不显示,因为我想要
,但我想作为
和我的代码是
for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#0079AD"));
((TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title)).setTextColor(Color.parseColor("#8CD7F2"));
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#009ED6"));
我怎样才能解决这个问题?
答
为了获得效果,我不想使用可绘制图像,因为我得到的结果与我的几乎相同。
ImageView view1;
TabHost tabHost;
tabHost = getTabHost()
TabHost.TabSpec spec;
Intent intent;
view1 = new ImageView(this);
view1.setOnTouchListener(view1Touch);//for identifying touch newly added.
view1.setBackgroundResource(R.drawable.tab_image);
intent = new Intent().setClass(this, AnohterActivity.class);
spec = tabHost.newTabSpec(TAG_1).setIndicator(view1).setContent(
intent);
tabHost.addTab(spec);
=======================
OnTouchListener view1Touch = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.setBackgroundResource(R.drawable.tab_focus);
}
}
,你可能已经添加TabChangeListener。
但如果我使用这个如何实现选择器?请指导我。 – 2011-04-08 06:25:34