1

I have a problem with my android app. I'm using a simple Textview with a vertical scrollBar to display lyrics from a song. The problem is that in my activity I set a Onclick event on this same Textview. So when I scroll the lyrics in the textview, the activity registers a click event when I release my finger from the screen. I don't want the onClick event to happen after I scroll.

Here is what I have done so far but it does not work really well since im using a onLongClick event wich is not precise enough:

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;
    }

what can I do to make it more "accurate" (so I dont have to make a longClick for it to work)

thanks!

SubbaReddy PolamReddy
  • 2,083
  • 2
  • 17
  • 23
muchwow
  • 715
  • 7
  • 22
  • please refer this link as i have handled both click event & LongClick event on the same button without any conflict.Hope u'll get something out of it.http://stackoverflow.com/questions/11374444/clicklistener-and-longclicklistener-on-the-same-button/11374496#11374496.Hope this will help you and implement this text instead of button – AkashG Nov 27 '12 at 04:54

1 Answers1

3

Put your textview inside scrollview.

<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>

Then it should work properly. Hope it helps

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124