2017-10-15 4 views
0

다음은 활동 (예 : 테스트)을 통해 클릭 연결되는 목록 조각을 설정하는 첫 번째 코드입니다. 다음 위치의 Android 문서 예제를 따랐습니다 : List Fragment ExampleonListItemClick은 "never used"로 표시됩니다.

그러나 onListItemClick은 "never used"로 표시됩니다. 나는 응용 프로그램을 실행하면 내 목록이 나타납니다,하지만 난 그것의 항목을 클릭하면 난 그냥 반환 된 다음 얻을 :

D/ViewRootImpl : ViewPostImeInputStage ACTION_DOWN

는 XML :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.example.administrationuser.piclo.ListViewFragment" 
     tools:showIn="@layout/activity_list_view" 
     tools:layout_editor_absoluteY="0dp" 
     tools:layout_editor_absoluteX="0dp" 
     > 

    <FrameLayout 
     android:id="@+id/list_container_id" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     tools:layout_editor_absoluteY="8dp" 
     tools:layout_editor_absoluteX="8dp"> 

     <ListView 
      android:id="@android:id/list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:drawSelectorOnTop="false" > 
     </ListView> 

    </FrameLayout> 

</android.support.constraint.ConstraintLayout> 

을 여기에 목록 조각이 있습니다 :

답변

0

나는이 문제를 해결했다. 노련한 안드로이드 개발자라면 누구나 쉽게 알 수있을 것입니다.하지만이 트랩에 빠질 수있는 초보자를위한 것입니다 ....

... 부모 작업 'ListView'의 이름을 지정하지 마십시오. .. 그것은 ListView의 어떤 클래스를 재정의해야하는지 알지 못하기 때문에 OnListItemClick 재정의를 혼란스럽게합니다. 실제 활동이나 불행히도 부모 활동의 최악의 선택을 통해 생성 된 것일 수 있습니다.