mlvGuaranteedInfo = (ListView) mvContent.findViewById(R.id.lv_guaranteed_info); mlvGuaranteedInfo.setOnItemClickListener(new GuaranteedInfoListener());
/** * ListView點擊效果 */ private class GuaranteedInfoListener implements OnItemClickListener { @Override public void onItemClick(AdapterView<?> parent, View arg1, int position, long id) { ListView listView = (ListView) parent; int visiblePostion = listView.getFirstVisiblePosition(); for (int i = 0; i < mlvGuaranteedInfo.getChildCount(); i++) { if (i == position - visiblePostion) { // mlvGuaranteedInfo.getChildAt(i).setBackgroundResource(R.color.color_image_data_line_choosen); if (mintGuaranteedInfoPosition == i) { mlvGuaranteedInfo.getChildAt(i).setBackgroundResource(R.drawable.selector_bg_listview_item); } else { mlvGuaranteedInfo.getChildAt(i).setBackgroundResource(R.color.color_image_data_line_choosen); } } else { mlvGuaranteedInfo.getChildAt(i).setBackgroundResource(R.drawable.selector_bg_listview_item); } } } }