1
我想創建一個對話框,包含我的網站的鏈接(在Android),並希望手機的瀏覽器打開時,用戶點擊鏈接。我目前有:如何textview和安卓
@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; }
上面的代碼觸發NullPointerException異常中包含lblClickable.setText(Html.fromHtml(htmlText));
任何建議行?代碼有什麼問題?
感謝很多是解決它 – maxsap 2010-11-20 08:37:19