如何使用textview和android

如何使用textview和android,android,Android,我想创建一个包含我的网站链接的对话框(在android上),并希望在用户点击链接时打开手机浏览器。我目前有: @Override protected Dialog onCreateDialog (int id){ Dialog dialog = new Dialog(MyActivity.this); dialog.setContentView(R.layout.custom_dialog); d

我想创建一个包含我的网站链接的对话框(在android上),并希望在用户点击链接时打开手机浏览器。我目前有:

@Override 
protected Dialog onCreateDialog (int id){
Dialog dialog = new Dialog(MyActivity.this);                                                

dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("MyTittle");
ImageView image = (ImageView)dialog.findViewById(R.id.image); 

image.setImageResource(R.drawable.launcher_icon);
TextView lblClickable = (TextView)findViewById(R.id.text); 
String htmlText = "Link to my <a HREF='http://www.rainbowbreeze.it'>site</a>"; 
 lblClickable.setText(Html.fromHtml(htmlText));
//needed to enable click on the link     
lblClickable.setMovementMethod(LinkMovementMethod.getInstance());
return dialog; }
@覆盖
受保护的对话框onCreateDialog(int id){
Dialog Dialog=新建对话框(MyActivity.this);
setContentView(R.layout.custom_对话框);
dialog.setTitle(“MyTitle”);
ImageView image=(ImageView)dialog.findViewById(R.id.image);
setImageResource(R.drawable.launcher_图标);
TextView lblClickable=(TextView)findViewById(R.id.text);
字符串htmlText=“链接到我的”;
lblClickable.setText(Html.fromHtml(htmlText));
//需要启用单击链接
lblClickable.setMovementMethod(LinkMovementMethod.getInstance());
返回对话框;}

上面的代码在包含
lblClickable.setText(Html.fromHtml(htmlText))的行中激发NullPointerException有什么建议吗?代码出了什么问题?

我认为
lblClickable
为空,这行可能是错误的:

TextView lblClickable = (TextView)findViewById(R.id.text); 
更正:

TextView lblClickable = (TextView)dialog.findViewById(R.id.text);