TextView中的可点击单词

| 我想在活动中显示某种“格式化的”文本。 此TextView中的某些单词(例如,粗体格式)应该是可单击的。 当用户单击它们时,应该显示敬酒消息。 有可能在Android中这样做吗? 谢谢     
已邀请:
我可能找到了对我来说更好,更灵活的解决方案。 我可以在其中使用WebView,HTML和JavaScript函数来调用我的android应用程序中的方法。
public class MainScreen extends Activity 
{

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        WebView webview = new WebView(this);
        setContentView(webview);
        String data = \"Test <u onClick=\\\"showAndroidToast(\'test\')\\\">it</u>\";
        String js_data = \"<script type=\\\"text/javascript\\\">function showAndroidToast(toast){Android.showToast(toast);}</script>\";
        webview.loadData(data + js_data, \"text/html\", \"utf-8\");

        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);

        webview.addJavascriptInterface(new JavaScriptInterface(this), \"Android\");        
    }    

    public class JavaScriptInterface
    {
        Context mContext;

        /** Instantiate the interface and set the context */
        JavaScriptInterface(Context c)
        {
            mContext = c;
        }

        /** Show a toast from the web page */
        public void showToast(String toast)
        {
            Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
        }
    }
}
    

要回复问题请先登录注册