Reputation: 423
I want text click event in a dialogbox
. but when I click on image it shouts down...
when I should click on the link it should move to the browser and open that link...
please help...
this is my code:
ivworkshivalik.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
final Dialog dialog = new Dialog(Ourwork.this);
dialog.setContentView(R.layout.shivalik);
dialog.setTitle("SHIVALIK PROJECTS");
TextView tvshivalik1 = (TextView) dialog.findViewById(R.id.tvshivalik1);
TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
tvshivalik2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.shivalikprojects.com/"));
startActivity(browserIntent);
}
});
dialog.show();
}
});
Upvotes: 0
Views: 873
Reputation: 814
Insted of this
TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
you should try
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
Upvotes: 1
Reputation: 47817
You should replace this
TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
With
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
Upvotes: 3
Reputation: 133560
You need to initialize as below. The same way you initialized tvshivalik1
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
assuming your shivalik.xml
has a textview with id tvshivalik2
.
Upvotes: 0