2012-03-05 2 views
2

현재 여러 텍스트 뷰가있는 선택 윤곽을 포함하는 안드로이드 응용 프로그램을 수행하고 있습니다. 텍스트 뷰를 클릭하면 텍스트 뷰의 내용을 표시하고 싶습니다. .i 선택 윤곽을위한 코드가 있지만 작동하지 않습니다. 여러 텍스트보기의 경우. 나는 textview가 차례로 하나씩 움직여야한다.다중 텍스트 뷰 및 포커스가있는 선택 윤곽

PLZ 날 도와 .....

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TextView 
    android:id="@+id/mywidget" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:lines="1" 
    android:ellipsize="marquee" 
    android:fadingEdge="horizontal" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:textColor="#ff4500" 
    android:text="Simple application for marquee with example as shown" /> 


<TextView 
    android:id="@+id/mywidget1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:lines="1" 
    android:ellipsize="marquee" 
    android:fadingEdge="horizontal" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:textColor="#ff4500" 
    android:text="haihaihaihaihaihaiahaiahaiahaiahaiahaiahaiahaiahaiahaiahiaha" 


    /> 



    </RelativeLayout> 

자바 코드

TextView tv = (TextView) this.findViewById(R.id.mywidget); 
    tv.setSelected(true); 

    TextView tv1 = (TextView) this.findViewById(R.id.mywidget1); 
    tv1.setSelected(true); 

답변

2
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:orientation="vertical"> 

    <TextView 
     android:id="@+id/mywidget" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:ellipsize="marquee" 
     android:fadingEdge="horizontal" 
     android:lines="1" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:scrollHorizontally="true" 
     android:text="Simple application for marquee with example as shown" 
     android:textColor="#ff4500" /> 

    <TextView 
     android:id="@+id/mywidget1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:ellipsize="marquee" 
     android:fadingEdge="horizontal" 
     android:lines="1" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:scrollHorizontally="true" 
     android:text="haihaihaihaihaihaiahaiahaiahaiahaiahaiahaiahaiahaiahaiahiaha" 
     android:textColor="#ff4500" /> 

</LinearLayout> 

만들고,이 번

+0

이 코드가 완벽하게 작동하지만 난 당신이 단지 하나의 텍스트 뷰를 텍스트를 CONCAT하고 사용할 필요가 그리고 다른 – user1057197

+0

후 하나를 움직이는 텍스트 뷰를 필요로 –

+0

두 개의 텍스트 뷰는 다른 세부 사항을 포함하고 난 내가 텍스트 뷰를 클릭하여 각 textview.when에 대한 집중이 필요 그 textview의 세부 사항을 보여 주어야합니다 – user1057197

0

이 잇달아 작업을 진행하려고하고 시작 setSelected (true)를 사용해 선택된 텍스트 뷰를, n 마이크로 초의 설정 시간 간격으로 1 개씩 프로그래밍 방식으로 설정하는 새로운 thread thread.sleep (n)를 사용해 설정할 수 있습니다. 또한 setSelected (false)를 사용하여 초기에 모든 텍스트보기를 선택 취소로 설정하는 것을 잊지 마십시오. 개인적으로 테스트 해본 적은 없지만 제대로 작동 할 것이라고 확신합니다.

관련 문제