is it possible in android to make text view clickable if yes then how ??and if not then what will be the way for make a label clickable??i want to implement a call activit
textView.setOnClickListener(new View.OnClickListener());
Have you tried this?
you can set a onclick listener to the texview like button.infact button inherits the properties from textview.
Simply try this one:-
Implement View.OnClickListener, then simply apply switch case and define the id of your text view in the case and pass the intent.
example:-
@Override
public void onClick(View v) {
//TODO Auto-generated method stub
switch (v.getId()) {
case R.id.textView:
startActivity(new Intent(this,CalledClass.class));
break;
default:
break;
}
//here textView is id for the textView I chose.
TextView is also derived of View like- EditText,ListView etc.,so we can use
textView.setOnClickListener(new View.OnClickListener());
First in your java file cast your TextView
by xml id
TextView tv = (TextView)findViewById(R.Id.textView1);
then,
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
Though it was long ago when you asked your question. But I think that the right thing to attain what you wanted is to set TextView xml attribute android:autoLink. For example:
<TextView
...
android:autoLink="phone" />