2010-12-29 14 views
1

기본적으로 2 개의 TextViews가있는 행이있는 ListView가 있습니다. 그러나 이러한 텍스트 뷰 중 하나는 HorizontalScrollView 내부에 있습니다.전체 행을 강조 표시하는 방법 (HorizontalScrollView 사용)

내가 TOUCH 모드에서 다음 동작을 원하는 :

1) 사용자가 TextViews 중 하나를 누르면, 전체 행이 강조되어야한다. 그는 왼쪽/오른쪽으로 첫 번째 텍스트 뷰를 스크롤 할 수 있지만 전체 행은 강조 표시 상태를 유지해야합니다.

2) 사용자가 "press"를 다시 입력하면 사용자가 다른 행을 누르거나 목록을 위/아래로 스크롤 할 때까지 행을 강조 표시해야합니다.

미리 감사드립니다.

행 레이아웃 :

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight" 
> 
    <HorizontalScrollView 
     android:id="@+id/frmclientes_listview_linha_scrollView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center_vertical" 
     android:fillViewport="true" 
     android:scrollbars="none" 
     android:scrollbarAlwaysDrawHorizontalTrack="false" 
     android:scrollbarAlwaysDrawVerticalTrack="false" 
     android:fadingEdge="horizontal" 
     android:fadingEdgeLength="30sp" 
    > 
     <TextView 
      android:id="@+id/frmclientes_listview_line_firstline" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:ellipsize="marquee" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:gravity="center_vertical" 
      android:focusable="false" 
      android:lines="1" /> 
    </HorizontalScrollView> 

    <TextView 
     android:id="@+id/frmclientes_listview_line_secondline" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_below="@+id/frmclientes_listview_linha_scrollView1" 
     android:ellipsize="marquee" 
     android:gravity="center_vertical" 
     android:lines="1" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

</RelativeLayout> 
+0

를 오버라이드 (override) 할 수 있어야한다? –

답변

0

당신은 당신이 HorizontalScrollView의 배경을 변경하지 않는 이유는 HorizontalScrollView.draw()

public class HorizontalScrollViewHighlight extends HorizontalScrollView { 
    public boolean isHighlighted = false; 
    public HorizontalScrollViewHighlight(Context context) { 
     super(context, null); 
    } 
    @Override 
    public void draw(Canvas canvas) { 
     super.draw(canvas); 
     if (isHighlighted) 
      // highlight code 
     else 
      // non-highlighted code 
    } 
} 
관련 문제