У меня есть следующий строковый ресурс
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
package com.example.game;
import androidx.fragment.app.Fragment;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.text.HtmlCompat;
import com.example.game.databinding.FragmentInterestingFactsBinding;
public class FR_InterestingFacts extends Fragment {
private FragmentInterestingFactsBinding binding;
public FR_InterestingFacts() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the screen orientation to landscape
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentInterestingFactsBinding.inflate(inflater, container, false);
String formattedText = getString(R.string.info_efficiency_link);
binding.tvFactsEfficiency.setText(HtmlCompat.fromHtml(formattedText, HtmlCompat.FROM_HTML_MODE_LEGACY));
binding.tvFactsEfficiency.setMovementMethod(LinkMovementMethod.getInstance());
return binding.getRoot();
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... -clickable