2014-08-31 115 views
0

是否有可能在AlertDialog中有可点击的内部链接(锚链接)?这个链接不应该调用外部网页,它应该只跳转到achor链接。 我试过它与href =“#jumptarget”和<a name="jumptarget">。但是我得到了一个错误。如何在Android AlertDialog中获得可点击的HTML内部(锚点)链接?

我的HTML代码:

<!DOCTYPE html> 
<html> 
    <body> 
    <h1><a name="jumpstart" href="#jumptarget">Jump</a></h1> 
    <p>Some Text... </p> 
    <h1><a name="jumptarget">Jump Target</a></h1> 
    </body> 
    </html> 

我的Java代码:

int listId = R.raw.instructions; 
    String instructions = ""; 
    instructions = loadTextRessource(listId); 
    TextView msg = new TextView(this); 
    msg.setText(Html.fromHtml(instructions)); 
    msg.setMovementMethod(LinkMovementMethod.getInstance()); 
    msg.setClickable(true); 
    AlertDialog.Builder alertDlg = new AlertDialog.Builder(this); 
    alertDlg.setTitle("Instructions"); 
    alertDlg.setView(msg); 
    alertDlg.setPositiveButton("OK", null); 
    alertDlg.show(); 

的显示结果是可点击的,但我得到一个ActivityNotFoundException例外。

回答

0

我找到了解决办法:用WebView代替TextView