views:

198

answers:

2

I've a border set around a drawable using LinearLayout (bg: rounded rectangle).

The drawable and the border is used as a tab view. I'd like to change the border color of the tab when it is selected.

How can I do this?

Color state list doesn't seem to work as the view being selected is not the shape (i.e border) but the tab. Drawable state list doesn't seem to work either as I'm trying to swivel between views, not drawables. Moreover, I can't find any "onSelectedListener" of the sort...

A: 

You need to make an OnClickListener to handle clicks, and get it to change the appropriate background:

private OnClickListener tabClick(Context mContext){
  @Override
  onClick(View v){
    v.setBackgroundResource(R.drawable.active);
  }
}
myTab.setOnClickListener(tabClick);
fredley
A: 

The solution is to call setOnTabChangeListener in the TabHost and then change everything manually.

Gilbert