Java 试图使用setMovement在应用程序中启用单击链接,但我的AboutFrag应用程序崩溃

Java 试图使用setMovement在应用程序中启用单击链接,但我的AboutFrag应用程序崩溃,java,android,xml,Java,Android,Xml,我正在开发我的应用程序,还是这方面的新手。我正在尝试像你们在网络开发中一样放置超链接。我在网上搜索过,似乎对太多似乎过于复杂的代码感到非常困惑。超链接正在创建中,但我无法单击它们将我发送到下面的网站。我已在Manifest.xml页面/文件中添加了互联网应用程序权限 我的fragment_about.xml textview如下所示: <TextView android:id="@+id/text2" android:layout_width="match

我正在开发我的应用程序,还是这方面的新手。我正在尝试像你们在网络开发中一样放置超链接。我在网上搜索过,似乎对太多似乎过于复杂的代码感到非常困惑。超链接正在创建中,但我无法单击它们将我发送到下面的网站。我已在Manifest.xml页面/文件中添加了互联网应用程序权限

我的fragment_about.xml textview如下所示:

<TextView
 android:id="@+id/text2"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:text="@string/data_about"/>

我的字符串是这样的:

<string name="data_about">
    
    1. <a href="https://www.wolfram.com/mathematica">Mathematica</a>
    2. <a href="https://www.nationalgeographic.com">Nat Geo</a>
    3. <a href="https://www.iucnredlist.org">IUCN Red List</a>
    4. <a href="https://www.awf.org">AWF</a>
    5. <a href="https://www.krugerpark.co.za">Kruger Park</a>
    </string> 
public class AboutFragment extends Fragment {
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        AboutViewModel aboutViewModel = new
                ViewModelProvider(this).get(AboutViewModel.class);
        View root = inflater.inflate(R.layout.fragment_about, container, false);
        final TextView textView = root.findViewById(R.id.text_about);
        aboutViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);

                TextView t2 = (TextView) textView.findViewById(R.id.text2);
                t2.setMovementMethod(LinkMovementMethod.getInstance());

            }
        });
        return root;
    }
}

1.
2.
3.
4.
5.
我的Java代码是这样的:

<string name="data_about">
    
    1. <a href="https://www.wolfram.com/mathematica">Mathematica</a>
    2. <a href="https://www.nationalgeographic.com">Nat Geo</a>
    3. <a href="https://www.iucnredlist.org">IUCN Red List</a>
    4. <a href="https://www.awf.org">AWF</a>
    5. <a href="https://www.krugerpark.co.za">Kruger Park</a>
    </string> 
public class AboutFragment extends Fragment {
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        AboutViewModel aboutViewModel = new
                ViewModelProvider(this).get(AboutViewModel.class);
        View root = inflater.inflate(R.layout.fragment_about, container, false);
        final TextView textView = root.findViewById(R.id.text_about);
        aboutViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);

                TextView t2 = (TextView) textView.findViewById(R.id.text2);
                t2.setMovementMethod(LinkMovementMethod.getInstance());

            }
        });
        return root;
    }
}
public类AboutFragment扩展了Fragment{
公共视图onCreateView(@NonNull layoutiner充气机,
视图组容器,捆绑包savedInstanceState){
AboutViewModel AboutViewModel=新建
ViewModelProvider(this.get)(关于viewmodel.class);
视图根=充气机。充气(R.layout.fragment\u about,container,false);
final TextView TextView=root.findviewbyd(R.id.text\u about);
aboutViewModel.getText().observe(getViewLifecycleOwner(),new Observer()){
@凌驾
公共void onChanged(@Nullable String s){
textView.setText;
TextView t2=(TextView)TextView.findViewById(R.id.text2);
t2.setMovementMethod(LinkMovementMethod.getInstance());
}
});
返回根;
}
}
非常感谢你的帮助。多谢各位