3
클릭 할 때 배경을 텍스트 뷰로 설정하려고합니다. 그러나 전체 레이아웃을 클릭하면 모든 텍스트 뷰가 배경을 변경합니다.레이아웃을 클릭하면 모든 텍스트 뷰 변경 색상이 발생합니다.
목록보기에서 항목으로 사용하는 레이아웃 파일이며이 목록의 항목을 클릭하면 모든 텍스트보기의 색이 녹색으로 바뀝니다.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:padding="6dip"
android:layout_width="fill_parent"
android:background="@drawable/lines"
android:orientation="vertical"
android:id="@+id/ll_main">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginTop="4dip"
android:id="@+id/ll_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="@style/VotePlus"
android:text="Plus"
android:id="@+id/tv_vote_plus"
android:background="@drawable/change_tv_bg"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="@style/VoteMinus"
android:text="Minus"
android:id="@+id/tv_vote_minus"
android:background="@drawable/change_tv_bg"/>
</LinearLayout>
</LinearLayout>
change_tv_bg 내용
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/green" /> <!-- focused -->
<item android:state_focused="true" android:state_pressed="true" android:drawable="@color/green" /> <!-- focused and pressed-->
<item android:state_pressed="true" android:drawable="@color/green" /> <!-- pressed -->
<item android:drawable="@android:color/transparent" /> <!-- default -->
</selector>
아무도이 문제가 발생한 적이 있습니까?
PS : 불쌍한 내 영어에 대한 미안 해요, 난 프랑스어 =) textViews와 전체 레이아웃이 목록보기 항목입니다
예 LinearLayout id ll_main은 ListView 항목입니다. state_pressed, selector (선택자)에 초점을 맞춘 다른 매개 변수를 시도해 보았습니다. 여러 색상을 사용하지만이 전역 레이아웃을 누를 때마다 모든 자식이 true로 눌려지고 false (선택기 파일에서)에 집중됩니다. 그리고 나는/해제 안드로이드 : descendantFocusability를 해제하고 안드로이드를 해제/duplicateParentState, 내 listview에 적용 mListView.setItemsCanFocus (거짓); ListView.setChoiceMode (ListView.CHOICE_MODE_SINGLE); 하지만 작동하지 않습니다. 나는 미치게된다 : / – Ahmet