** Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference**
Hey guys I'm going through this issue while I'm tryin to implemente something like a clickable view that takes me to a webView page, for the first one it worked pretty well, but as long as I tryied on the second one then... :
ImageView winIcon;
ImageView winBanner;
winIcon = findViewById(R.id.ptw); // Referenced to the icon
winBanner = findViewById(R.id.play_win_banner); // Refereced to the banner
String winUrlAdress = "https://1155.set.qureka.com"; //Url for the Views
winIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openCustomTab(winUrlAdress);
}
});
winBanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openCustomTab(winUrlAdress);
}
});
private void openCustomTab(String url) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
}
and also my xml for the second one:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@id/frml"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBaseline_toBottomOf="parent">
<ImageView
android:id="@+id/play_win_banner"
android:layout_width="match_parent"
android:layout_height="70dp"
android:src="@drawable/bannerads"
tools:ignore="SpeakableTextPresentCheck" />
</RelativeLayout>