Я пытаюсь установить метод click в своем проекте, но не могу подключить свой макет к данному фрагменту. Когда вы нажимаете значок Instagram, он должен открывать людей Instagram, но он только вылетает.
Код фрагмента:
public class SupportFragment extends Fragment {
@Nullable
ImageView vedoIg;
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_support,container,false);
vedoIg = v.findViewById(R.id.vedo_ig);
vedoIg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("http://instagram.com/v");
Intent instagram = new Intent(Intent.ACTION_VIEW, uri);
instagram.setPackage("com.instagram.android");
try {
startActivity(instagram);
}
catch (Exception e){
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://instagram.com/_u/v")));
}
}
});
return inflater.inflate(R.layout.fragment_support,container,false);
}
}
Папка макета:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/pozadina"
tools:context=".SupportFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="Contact us: "
android:textColor="#ffffff"
android:textSize="30dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:text="Vedo"
android:textColor="#ffffff"
android:textSize="30dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/vedo_ig"
android:layout_width="72dp"
android:layout_height="48dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="150dp"
app:srcCompat="@drawable/w_instagram"/>
Любой совет означал бы мир. Заранее спасибо: D <3 </p>