예를 들어 사용자 지정 어댑터 목록보기가 있고 목록 항목은 textview, imageView 등 다른 요소가 포함 된 레이아웃입니다. 선택한 목록 항목의 이미지 뷰의 색상을 어떻게 설정할 수 있습니까? 이 항목을 즐겨 찾기에 추가하고 싶을 때 노란색 색으로 좋아하는 별색을 변경하고 싶습니다. 당신의 아이를 얻을 수 있도록 문서에 따르면사용자 지정 어댑터의 항목에 특정 요소의 색 설정
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
이
https://developer.android.com/reference/android/widget/AdapterView.OnItemLongClickListener.html
, view
, 당신은 실제로 클릭 한 레이아웃입니다 :
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getActivity(), PlaceName[position] + " in favourite",
Toast.LENGTH_SHORT).show();
//Do smth here, set the color of element on item, add to favourite and something else
return true;
}
});
이 경우 전체 항목의 배경색을 변경하지만 목록 항목의 한 요소에 대해서만 색상을 변경해야합니다 –