Closed rashgaroth closed 3 years ago
What's the issue @rashgaroth?
here is the issue @AviranAbady :
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.setOnTouchListener(android.view.View$OnTouchListener)' on a null object reference
@rashgaroth please provide a sample project
@AviranAbady woops sorry mybad hehe
this is my ProfileFragment.java
public class ProfileFragments extends Fragment implements View.OnClickListener {
private ImageView settings;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_profile_fragments, container, false);
InitComponents(v);
settings.setOnClickListener(this);
return v;
}
void InitComponents(View v){
settings = v.findViewById(R.id.btSetting);
}
@Override
public void onClick(View v) {
CookieBar.build(getActivity())
.setCustomView(R.layout.dialog_settings)
.setCustomViewInitializer(new CookieBar.CustomViewInitializer() {
@Override
public void initView(View view) {
Button logout = view.findViewById(R.id.logoutButton);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Button button = (Button) v;
// Utils.showLongSnackBar(getActivity(), "berhasil");
button.setText("checked");
}
};
logout.setOnClickListener(listener);
}
})
.setEnableAutoDismiss(false)
.setSwipeToDismiss(true)
.setCookiePosition(CookieBar.BOTTOM)
.show();
}
}
and here is my dialog_settings.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/dialog_setting"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="@+id/logoutButton"
android:layout_width="290dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:layout_marginStart="62dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="62dp"
android:background="@drawable/rounded_outline_button"
android:gravity="center"
android:text="@string/logout_akun"
android:textColor="@color/merah" />
</RelativeLayout>
@rashgaroth you need to create all the other required views, you can keep them hidden if you dont neet them
I don't know why, but after figuring out for sometime.
Apparently, if you want to use customView
. You'll need to set the rootView in your customView to id.
How I figured out was that, the demo app that is provided has no issues with customView.
But, as soon I remove the rootView ID. It just freaks out.
android:id="@+id/cookie"
hey yo! this is my function for show the dialog custom view