시계

2012-09-18 3 views
0

내가 현재 시간을 보여줍니다 내 응용 프로그램에서 텍스트 뷰가 표시 될 때 ScrollingTextView하지, 난 ScrollingtextView.java시계

, 나는 ScrollingTextView의 aswell이 내 응용 프로그램에서이

private Handler handler = new Handler(); 


private Runnable runnable = new Runnable() 
{ 

public void run() 
{ 
    batteryLevel(); 
    if(clock_on == true) { 


     Handler clockUpdate = new Handler(); 
     clockUpdate.postDelayed(new Runnable() { 
       public void run() { 
        executeClock(); 
       } 
     }, 500); 



    } 
    handler.post(this); 






} 

public void executeClock() { 



    TextView timeTv = (TextView) findViewById(R.id.time); 

    long currentTime=System.currentTimeMillis(); 
    Calendar cal=Calendar.getInstance(); 
    cal.setTimeInMillis(currentTime); 
    String timeFormat24 = "%1$tH:%1$tM"; 
// String timeFormat12 = "%1$tI:%1$tM"; 
    String showTime=String.format(timeFormat24,cal); 
    timeTv.setText(showTime); 


} 

처럼 구현 워킹

public class ScrollingTextView extends TextView { 

public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
} 

public ScrollingTextView(Context context, AttributeSet attrs) { 
    super(context, attrs); 
} 

public ScrollingTextView(Context context) { 
    super(context); 
} 
@Override 
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { 
    if(focused) 
     super.onFocusChanged(focused, direction, previouslyFocusedRect); 
} 

@Override 
public void onWindowFocusChanged(boolean focused) { 
    if(focused) 
     super.onWindowFocusChanged(focused); 
} 


@Override 
public boolean isFocused() { 
    return true; 
} 

}

<com.doublep.example.ScrollingTextView 
      android:id="@+id/txt_lcd_message" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:ellipsize="marquee" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:scrollHorizontally="true" 
      android:singleLine="true" 
      android:textColor="#f82424" 
      android:textSize="30dp" /> 

가 ScrollingTextView 시계 경우 작동하지 않습니다 텍스트가 보임 시계가 보이면 시계가 보입니다. 그러면 ScrollingTextView가 완벽하게 작동합니다.

왜 이런 일이 발생합니까? 어떻게 해결할 수 있습니까?

편집 : 나는 ScrollingTextView 작업 시작 시계를 지연하지만 곧 클럭 텍스트 뷰가 현재 시간으로 설정됩니다 같이 ScrollingTextView는

UPDATE 작업 중지 된 경우 : 테스트의 비트가 난 것으로 나타났습니다 후 ScrollingTextView 작동하지만 executeClock() 메서드가 실행될 때마다 ScrollingTextView 애니메이션이 다시 설정되고 다시 시작됩니다.

답변

0

동일한 뷰 그룹에 시계 textview 및 scrolltextview가 있습니까? 그래서 예를 들어, 그것들은 모두 동일한 선형 또는 상대 레이아웃의 모든 하위 뷰입니까? 그것들을 분리하여 다른 뷰 그룹의 자식으로 만들어보십시오. 저를 위해 한 번 일하고 당신을 위해 너무 일할지도 모른다

+0

시계는 주요 배치> central> central_console에있다 그리고 ScrollText는 주요 배치에있다> lcd> lcd_screen – DoubleP90

+0

나는 나의 질문을 추가 정보로 새롭게했다 – DoubleP90

관련 문제