ben
ben

Reputation: 393

ontouchlisteners in textviews

i am trying to implement a ontouchlistener in each and every textview that i have so that when i touch the textviews it would do a vibration

however i have this problem "cannot reduce visibility of the inherited method from view.ontouchlistener"

anyone has any idea what am i doing wrong? i have implemented the OnTouchListener already

        for (int i = 0; i < counter; i++)
        {
                tv[i] = new TextView(this);
                tv[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
                tv[i].setTextSize(textSize);
                tv[i].setText(""+singleText[i]);
                tv[i].setOnTouchListener(this);
                linearLayout.addView(tv[i]);
        }
        setContentView(linearLayout);

    }
    catch (IOException e) {
        //You'll need to add proper error handling here
    }       
}

private boolean onTouch(View v, MotionEvent event)
{
    vibratePattern();
    return true;
}

Upvotes: 1

Views: 442

Answers (1)

Dmitry Ryadnenko
Dmitry Ryadnenko

Reputation: 22512

just make this onTouch() method public

public boolean onTouch(View v, MotionEvent event)
{
    vibratePattern();
    return true;
}

Upvotes: 2

Related Questions