ExpandableList에서 group layout에 다음과 같이 버튼을 추가 했더니 버튼은 클릭이 되지만 group 클릭할 수 없는 경우가 있습니다.
- list_group.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/listTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textColor="@android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp" />
<Button
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_alignParentRight="true"
android:text="Play" />
</RelativeLayout>
</LinearLayout>
이런 경우 다음과 같이 xml 레이아웃에서 버튼 포커스를 false로 설정한 다음 기존 게시물을 기반으로 이를 변경하고 focusable을 false로 동적으로 설정했습니다
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/listTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textColor="@android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp" />
<Button
android:layout_width="80dp"
android:layout_height="60dp"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_alignParentRight="true"
android:text="Play" />
</RelativeLayout>
</LinearLayout>
'android' 카테고리의 다른 글
안드로이드 리스트뷰에 버튼 넣기. (Android ListView with Button) (0) | 2024.10.10 |
---|---|
Java에서는 문자열 목록에서 빈 요소를 제거 (0) | 2024.10.10 |
Kotlin의 목록에서 null 및 빈 값 제거 (1) | 2024.10.10 |
[JAVA] Java의 String Empty 와 Blank 체크하기 (0) | 2024.10.10 |
[구글플레이 개발자 콘솔] 앱 검토에 로그인 사용자 인증 정보 입력 (0) | 2024.10.10 |