Pretty new to java. Already tried to implement existing tutorials but couldn't get it to work. Can someone tell me what to change in my HomeFragment.java to make the link clickable in the app?
XML:
XML
<TextView
android:id="@+id/textviewid"
android:autoLink="all"
android:gravity="center|top"
android:linksClickable="true"
android:text="@string/teststring"
android:textAllCaps="false"
android:textSize="12sp"
android:textStyle="bold" />
Alles anzeigen
Code: strings.xml
<string name="teststring"> <a href="https://google.com">test</a></string>
Code: HomeFragement.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
public class HomeFragment extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}
}
Alles anzeigen