I just started working with clickable TextViews in Eclipse. The line in the code below:
t2.setOnClickListener(this); seems to be having a problem.
I have tried a variety of methods like setOnTouchListener etc. to handle the click events of a user clicking my TextViews but I am having trouble determining which method (if any) is appropriate behind clickable TextViews.
public class Soundboard extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.soundboard);
TextView t2 = (TextView) findViewById(R.id.textView5);
t2.setFocusable(true);
t2.setOnClickListener(this);
t2.setOnClickListener(new View.setOnClickListener() {
public void onClick(View view) {
mp.start();
}
});
}
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}
});
OR
This is the right way of setting on click listeners.