listview默认选择第一项,点击换子项背景图

(不是大神,没有几百子项目,去你丫的)
private int last_item_position ;
    

    @Override
    public void onItemClick(AdapterView<?> arg0, View view, int position,
            long arg3) {
    
        // 取消合成
        mTts.stopSpeaking();
        isSpeaking = 0;

        PoiList poiList = poiListList.get(position);
        List<String> lStrings = poiList.poiContent;
        search_word_title.setText(poiList.poiName);
        tv_place.setText(poiList.poiSpotName);
        String contentUri = lStrings.get(0);
        downLoadContent(contentUri);

        ImageView imageView = (ImageView) view
                .findViewById(R.id.search_listview_item_img);

    
        last_item_position = position;
        adapter.notifyDataSetChanged();
    }


    public class SearchAdapter extends
            ArrayAdapter<GetResultFromPOIName.PoiList> {
        private int resourceId;
        private ImageView imageView;
        

        public SearchAdapter(Context context, int textViewResourceId,
                List<GetResultFromPOIName.PoiList> objects) {
            super(context, textViewResourceId, objects);
            resourceId = textViewResourceId;
        }
  
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            PoiList poiList = getItem(position);
        
            

            TextView newsTitleText = (TextView) convertView
                    .findViewById(R.id.news_title);
            imageView = (ImageView) convertView
                    .findViewById(R.id.search_listview_item_img);
            imageView.setBackgroundResource(R.drawable.image_floor_gary);
     if (last_item_position == position) {
imageView.setBackgroundResource(R.drawable.image_floor_color);
            } else {

                imageView.setBackgroundResource(R.drawable.image_floor_gary);
            }


    
            return convertView;
        }

转载于:https://www.cnblogs.com/520-1314/p/5051553.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值