开发者

change background of textview for listview item get focused

i have this listview

change background of textview for listview item get focused

each listview item has a 开发者_StackOverflowtextview that have background , i want to change the background of the textview of listview item get focused .


You should use Selector.
Edit: Use selector drawable as a background for ListView elements, or specify a android:listSelector for a ListView


you have change background color in onfocusChangeListener. Try with following code,

livView.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {

                TextView tv=(TextView)v.findViewById(R.id.yourId);
                if(hasFocus){
                    tv.setBackgroundColor(bg_color);
                }
            }
        });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜