Android : listView 클릭시 하이라이트 비활성화 행을 터치 할 때 발생하는 주황색

listView 행을 터치 할 때 발생하는 주황색 하이라이트를 비활성화하고 싶습니다. 지금까지 내 XML에서 다음을 시도했습니다.

android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"

추가 정보 : 사용자 가이 listView 객체의 화면을 터치 할 때 차이가 없도록하고 싶습니다.



답변

이것을 XML에 추가하십시오.

android:listSelector="@android:color/transparent"

그리고 문제의 경우 이것이 효과가있을 수 있습니다 (확실하지 않으며 더 나은 해결책이 있는지 모르겠습니다).

TextState에 ColorStateList 를 적용 할 수 있습니다 .


답변

RoflcoptrException의 대답은 트릭을 수행해야하지만 어떤 이유로 든 작동하지 않으므로 나를 위해 일한 솔루션을 게시하고 있습니다.

<ListView
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
/>


답변

주황색 하이라이트 효과는 ListView 의 스타일 입니다. 이 기사 는 listView 스타일을 재정의하는 방법에 대한 좋은 개요를 제공합니다.

기본적으로 현재 상태에 따라 다른 스타일 요소를 지정하는 선택기가 있습니다.

짧고 빠른 솔루션은 이것을 참조하십시오 https : //.com/a/12242564/185022


답변

에서 의 ListView : 사용 안 함 초점 강조 ,

ListAdapter다음 코드를 사용하도록 설정하면

ListAdapter adapter = new SimpleCursorAdapter(MyList, Layout, c,
                new String[] { "Name", "Score" }, to)
{
    public boolean areAllItemsEnabled()
    {
        return false;
    }
    public boolean isEnabled(int position)
    {
        return false;
    }
}; 

이것은 BaseAdapter클래스 를 재정의합니다 . 또한 셀 사이의 흰색 테두리를 취소합니다.


답변

이것을 listselector와 함께 XMl에 추가하십시오.

<ListView
android:cacheColorHint="@android:color/transparent"
android:listSelector="@android:color/transparent"/> 


답변

당신이 사용하는 경우 ArrayAdapter또는 BaseAdapter목록 항목을 채 웁니다. 방법 및 수익 .OverrideisEnabledfalse

 @Override
  public boolean isEnabled (int position) {
    return false;
  }


답변

가상 및 실제 기기에서 ‘Google’을 몇 번 테스트하고 테스트 한 결과 아래 코드가 작동하는 것을 알 수 있습니다.

ArrayAdapter<String> myList = new ArrayAdapter<String>(this, R.layout.list_item, strText) {
    public boolean isEnabled(int position)
    {
            return false;
    }
};

areAllItemsEnabled()부분을 생략했습니다 .