2014-08-31 59 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

相關問題