Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

android - TextView onClick not responding to single tap

I have a TextView with the following assignment code:

Answer1TextView = (TextView) findViewById(R.id.editText1);
Answer1TextView.setOnClickListener(answer1TextViewListener);

and here is my onClickListener:

private  OnClickListener answer1TextViewListener = new OnClickListener() 
{
    public void onClick(View v) 
    {
        if(Answer1Win){
            Toast.makeText(QuizScreen.this,"Correct ",2).show();
        } else
        {
            Toast.makeText(QuizScreen.this,"Incorrect, Pick Another Answer",2).show();
        }
    }
};  

My problem is the Toast only is displayed after a double tap. I cannot find a setting the drives this behavior, what could be set wrong to not display after a single tap.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The first click just sets the focus to the TextBox then the second click actually gets handled as a click. Rather than using an onClickListener, you may have better luck with an onFocusChangeListener


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...