【问题标题】:how to link text of text view to web site [duplicate]如何将文本视图的文本链接到网站[重复]
【发布时间】:2014-02-24 22:18:58
【问题描述】:

我知道这该死的简单问题..但是我用很多方法学习了很多教程..你能告诉我将文本视图中的文本动态链接到网站的最简单方法..意味着我不想包含链接将 b 显示在 web..hope 中的 likw href 标记的文本名称;;得到我的问题。

<TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:text="PoliticiansNpolitics.in"
        android:textColor="#4169E1"
        android:textAppearance="?android:attr/textAppearanceLarge" />

我希望 ABOVE TEXT 在点击时重定向到 google.com

【问题讨论】:

    标签: android textview


    【解决方案1】:

    您可以为文本视图提供点击监听器,如下所示

     tv.setOnClickListener(new OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://www.google.com"));
                        startActivity(browserIntent);
                    }
                });
    

    tv 是你的 textview 的 id

    【讨论】:

    • 我不想将链接名称放在文本中。我不想在文本中显示链接名称..点击文本时它应该指向它
    • @user3336646 检查编辑的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多