2010-11-19 13 views
1

私は自分のサイト(アンドロイド上)のリンクを含むダイアログを作成したいと考えており、ユーザーがリンクをクリックしたときに電話機のブラウザを開きたいと思っています。私は現在持っている:how to textview and 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; } 

上記のコードはlblClickable.setText(Html.fromHtml(htmlText));任意の提案を含む行にNullPointerExceptionが発射しますか?コードの何が間違っていますか?

答えて

0

私はlblClickableがnullだと思い、この行はおそらく間違っている:

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

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

おかげで、それを解決し、多く – maxsap