2012-11-27 3 views
1

내 안드로이드 앱에 문제가 있습니다. 저는 노래에서 가사를 표시하기 위해 세로 scrollBar가있는 간단한 Textview를 사용하고 있습니다. 문제는 내 활동에서이 동일한 Textview에서 Onclick 이벤트를 설정한다는 것입니다. 그래서 textview에서 가사를 스크롤하면 스크린에서 손가락을 뗄 때 액티비티가 클릭 이벤트를 등록합니다. 스크롤 한 후 onClick 이벤트가 발생하는 것을 원하지 않습니다. (내가 무엇을 할 수 있는지android는 TextView에서 스크롤 및 클릭 이벤트를 처리합니다.

public class NowPlayingActivity extends Activity implements ckListener,OnLongClickListener 
{ 
    private TextView lyrics; 
    private static final String TAG_LYRICS = "LYRICS"; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     this.lyrics = (TextView) this.findViewById(R.id.now_playing_Lyrics); 
     this.lyrics.setOnClickListener(this); 
     this.lyrics.setMovementMethod(new ScrollingMovementMethod()); 
     this.lyrics.setOnLongClickListener(this); 
} 
public void onClick(View v) 
{ 
    String tag = (String) v.getTag(); 
    if (tag.equals(NowPlayingActivity.TAG_LYRICS)) 
    { 
     if (this.scrolled) //this way, the click action doesnt occur after a scroll 
     { 
      this.scrolled = false; 
     } 
     else 
     { 
      this.scrolled = false; 
      this.artwork.setVisibility(View.VISIBLE); 
      this.lyrics.setVisibility(View.GONE); 
     } 
    } 
    public boolean onLongClick(View arg0) 
    { 
     this.scrolled = true; 

     return this.scrolled; 
    } 

이 더 "정확한"만들 : 여기

내가 지금까지했던하지만이 onLongClick 이벤트 느릅 나무가 충분히 정확하지 사용하여 메신저 때문에 정말 잘 작동하지 않는 것입니다 그래서 작동하지 않는 longClick을 만들어야합니다.)

감사합니다!

+0

나는 어떤 conflict.Hope u'll 그것으로부터 뭔가를 얻을거야 같은 버튼에 대한 클릭 이벤트 및 LongClick 이벤트를 모두 처리 한 대로이 링크를 참조하십시오 .http : //stackoverflow.com/questions/11374444/ clicklistener-and-longclicklistener-on-the-same-button/11374496 # 11374496. 희망이 당신을 도울 것입니다 대신 버튼 – AkashG

답변

2

스크롤 뷰에 텍스트 뷰를 넣으십시오.

<ScrollView 
     android:id="@+id/content_scroll" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="7dip" 
     android:scrollbars="none" > 

     <TextView 
      android:id="@+id/fileContent" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dip" /> 
    </ScrollView> 

그러면 올바르게 작동합니다. 희망이 도움이

+0

이 텍스트를 구현합니다. 글쎄, 난 정말 두 가지 방법이 다르지만 어쨌든 그것은 효과가! 감사! – jumojer

관련 문제