2011-11-27 6 views
3

다른 표 행이 있으며 각 표에는 클릭 할 수없고 선택할 수없는 정보 텍스트가 포함되어 있습니다. 하지만 에뮬레이터에서이 코드를 실행하면 텍스트를 항상 클릭 할 수 있습니다.레이아웃 XML에서 TextView의 텍스트를 unclickable로 만들려면 어떻게해야합니까?

즉, 텍스트 블록을 클릭하면 색상이 어두운 회색으로 바뀝니다. 나는 그것을 바꾸기를 원하지 않는다. 나는 아무것도하지 않기를 바란다.

분명히 어두운 회색을 텍스트 색상으로 설정하여 사용자가 아무 것도 클릭하지 않는 것을 볼 수는 있지만 원하는 것은 아닙니다.

예제에서 볼 수있는 것과는 다른 속성을 이미 시도했지만 아무 것도 도움이되지 않았습니다. 또한, 실제로 TableRow 또는 TableRow 내부의 TextView를 클릭 할 수 없게 설정해야합니까? 당신이 attritbutes을 둘 필요가

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical|center_horizontal" 
    > 
    <ScrollView 
      android:id="@+id/scrollView" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical|center_horizontal"> 
    <TableLayout 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:stretchColumns="*" 
      android:clickable="false"> 
     <TableRow 
      android:layout_width="fill_parent" 
      android:background="#777777" 
      android:clickable="false"> 
      <TextView 
       android:id="@+id/heading" 
       android:text="This is the cool heading"    
       android:textColor="#FFFFFF" 
       android:layout_width="fill_parent" 
       android:textSize="14sp" 
       android:paddingLeft="5sp" 
       android:paddingRight="5sp" 
       android:paddingTop="2sp" 
       android:paddingBottom="2sp" 
       android:textStyle="bold" 
       android:clickable="false" 
       /> 
     </TableRow> 
     <TableRow 
      android:clickable="false" 
      android:linksClickable="false" 
      android:focusable="false" 
      android:focusableInTouchMode="false"> 
      <TextView 
       android:text="This is example text. It should not be clickable, but it is." 
       android:textSize="14sp" 
       android:paddingLeft="5sp" 
       android:paddingRight="5sp" 
       android:paddingTop="2sp" 
       android:paddingBottom="2sp" 
       android:scrollHorizontally="false" 
       android:inputType="textMultiLine" 
       android:linksClickable="false" 
       android:clickable="false" 
       android:focusable="false" 
       android:focusableInTouchMode="false" 
       android:layout_width="0sp" 
       /> 
       </TableRow> 
       </TableLayout> 
       </ScrollView> 
       </RelativeLayout> 
+0

전체 tablerow가 어두운 회색으로 변경되거나 텍스트 내부의 텍스트 만 darkgrey로 변경됩니까? –

+0

텍스트 만 회색으로 바뀝니다. – Bevor

답변

14

TextView에 android:longClickable="false"을 추가하면 해결책을 찾았습니다. TextView에서는 두 가지 설정 만 필요합니다.

android:longClickable="false" 
android:clickable="false" 

TableRow의 설정은 필요하지 않습니다.

+0

소호, 내가 왜 그랬지? –

2

: 또한 당신의 텍스트 뷰 요소에서

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

여기

은 예입니다. 지금은 행의 개별 요소가 아닌 행을 비활성화하는 것입니다.

+0

내 의심은 tablerow에 대한 모든 것을 차단 한 경우입니다. tablerow 내부에있는 textView에 대해 click 이벤트가 발생할 수있는 방법은 무엇입니까? –

+0

어, 그게 뭐야? 왜 그게 걱정 스러운가? 이 우려를 확인하기 위해 노력 했습니까? –

+0

실제로 @Bevor는 이미 언급 한 다른 속성을 시도했으며 마지막 Textview는 그가 위에서 언급 한 모든 속성을 추가했다고 표시합니다. –

관련 문제