如何检测Textview中的网站链接并使其可单击

Mou*_*Ali 4 database android hyperlink textview

伙计们我想在我的位于数据库中添加一个link像(/sf/)这样的网站的大文本textview我尝试直接添加它像这样的图像:

数据库中我的价值图片

数据库中我的价值图片

但它出现在表单上的应用程序中,Textview不像这个图像那样可点击:

输出应用

输出应用

protected void onPostExecute(String result) {

        // Parse les données JSON
        String id;
        String solution;
        try {
            JSONArray jArray = new JSONArray(result);
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject json_data = jArray.getJSONObject(i);
                id= json_data.getString("alltext");
                solution = json_data.getString("title");
                prob.setText(solution);
                sol.setText(id);
                // Résultats de la requête
            }
        } catch (JSONException e) {
            Log.e("log_tag", "Error parsing data " + e.toString());
        }

    }
Run Code Online (Sandbox Code Playgroud)

Ars*_*ool 8

首先将Text设置为TextView

lbl2.setText("hi http://google.com");
Linkify.addLinks(lbl2,Linkify.ALL);
Run Code Online (Sandbox Code Playgroud)

自动链接可点击链接和其他文本保持相同.


Fah*_*man 7

AutoLinkwebTextView它会自动检测链接

<TextView
    android:autoLink="web"
    android:text="This is Google http://www.google.com"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明