0

i want to make show case view in my apps, in first showcase page i want to show confirmation page that have two button ok or not, if ok then continue to next show case, if not will remove / hide showcase. but my ok button doesn't work right now, here is my code :

 // -------- First Show case ---------
 private void ShowCaseIntro(){
 mFancyShowCaseView = new FancyShowCaseView.Builder(this)
         .delay(1000)
         .customView(R.layout.tutorial, new OnViewInflateListener() {
             @Override
             public void onViewInflated(@NonNull View view) {

                 view.findViewById(R.id.btnNo).setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
                         mFancyShowCaseView.removeView();
                     }
                 });
                 view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
                         ShowCaseEditProfile();
                     }
                 });
             }
         }).closeOnTouch(false)
         .build();
 mFancyShowCaseView.show();
}

     // -------- Second Show case ---------
private void ShowCaseEditProfile (){
    mFancyShowCaseView = new FancyShowCaseView.Builder(this)
            .focusOn(imgEdit)
            .focusCircleRadiusFactor(2)
            .customView(R.layout.edit_tutorial, new OnViewInflateListener() {
                @Override
                public void onViewInflated(@NonNull View view) {
                    view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            mFancyShowCaseView.hide();
                        }
                    });
                }
            }).closeOnTouch(false)
            .build();
    mFancyShowCaseView.show();

}

here is where i call method ShowCaseIntro() :

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.activity_main);
    setDefaultToolbar(false);
    ShowCaseIntro();

}

Here is button xml file :

 <Button
            android:id="@+id/btnNo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="5dp"
            android:text="Tidak"
            android:textAllCaps="false"
            android:textColor="@color/colorPrimary" />

        <Button
            android:id="@+id/btnOK"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/btnNo"
            android:backgroundTint="@color/orange"
            android:text="OK !"
            android:textAllCaps="false"
            android:textColor="@color/white" />
9
  • What is FancyShowCaseView ? Is it a 3rd party lib . Commented Jan 23, 2018 at 7:45
  • yes.. github.com/faruktoptas/FancyShowCaseView
    – asqa
    Commented Jan 23, 2018 at 7:45
  • did you getting any error ? Commented Jan 23, 2018 at 7:54
  • no, my button just not work.. :)
    – asqa
    Commented Jan 23, 2018 at 7:55
  • where you call ShowCaseIntro() share more code . Commented Jan 23, 2018 at 7:56

1 Answer 1

3

when you are calling ShowCaseEditProfile() your mFancyShowCaseView is already attached so before calling ShowCaseEditProfile() call mFancyShowCaseView.removeView();

private void ShowCaseIntro(){
    mFancyShowCaseView = new FancyShowCaseView.Builder(this)
            .delay(1000)
            .customView(R.layout.tutorial, new OnViewInflateListener() {
                @Override
                public void onViewInflated(@NonNull View view) {

                    view.findViewById(R.id.btnNo).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            mFancyShowCaseView.removeView();
                        }
                    });
                    view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            //add this line
                            mFancyShowCaseView.removeView();
                            ShowCaseEditProfile();
                        }
                    });
                }
            }).closeOnTouch(false)
            .build();
    mFancyShowCaseView.show();
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.