码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-12-16 17:18:37      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

(不是大神,没有几百子项目,去你丫的)
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;
        }

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

标签:

原文地址:http://www.cnblogs.com/520-1314/p/5051553.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!