我想要dialogbox
中的文字点击事件。但当我点击图像时,它会大声喊叫......
当我点击链接时,它应该移动到浏览器并打开该链接...
请帮忙......
这是我的代码:
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();
}
});
答案 0 :(得分:3)
你应该替换这个
TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
使用
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
答案 1 :(得分:1)
而不是这个
TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
你应该试试
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
答案 2 :(得分:0)
您需要初始化如下。与初始化tvshivalik1
TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);
假设您的shivalik.xml
的文字视图标识为tvshivalik2
。