listview預設選擇第一項,點擊換子項背景圖,listview背景圖

來源:互聯網
上載者:User

listview預設選擇第一項,點擊換子項背景圖,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;        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.