我想在工具栏中添加带有可点击链接的文字
字符串设置:
<string name="q4"><a href="http://google.com/">news</a></string>
toolbar.xml设置:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:autoLink="web"
android:linksClickable="true"
android:text="@string/q4"/>
</android.support.v7.widget.Toolbar>
它可以显示“新闻”字样,但我无法点击它谷歌..如何让它点击谷歌? THX
答案 0 :(得分:0)
您可以使用Java代码完成此操作。您需要做的是将TextView标题赋予id,检索活动或片段中的TextView,然后调用以下内容:
SharedPreferences shared = getSharedPreferences("user_Info", Context.MODE_PRIVATE);
int user_id = (shared.getInt("User_Id", 0));
string address = (shared.getString("Addresss"));
希望这有帮助。
答案 1 :(得分:0)
删除android:autoLink =&#34; web&#34;在xml中,单击以使用“操作”视图意图导航到URL的文本视图。