0

I have a problem in setting TapTargetView for PreferenceSwitch in PreferenceScreen I want to set TapTargetView for PreferenceSwitch in preferenceScreen but the TapTargetView library method is built on Views and I can't pass PreferenceSwitch to TapTargetView

my code here:

public static void showSettingGuide(AppCompatActivity activity, Preference... view){
        new TapTargetSequence(activity)
                .targets(
                        TapTarget.forView(activity.findViewById(view[0].getLayoutResource()),activity.getResources().getString(R.string.night_mode),activity.getResources().getString(R.string.NightModeGuide))
                .cancelable(false),
                        TapTarget.forView(activity.findViewById(view[1].getLayoutResource()),activity.getResources().getString(R.string.automatic_night_text),activity.getResources().getString(R.string.AutoNightModeGuide))
                .cancelable(false),
                        TapTarget.forView(activity.findViewById(view[2].getLayoutResource()),activity.getResources().getString(R.string.keepScreenOn),activity.getResources().getString(R.string.keepScreenGuide))
                .cancelable(false),
                        TapTarget.forView(activity.findViewById(view[3].getLayoutResource()),activity.getResources().getString(R.string.appState),activity.getResources().getString(R.string.appStateGuide)))
                .listener(new TapTargetSequence.Listener() {
                    @Override
                    public void onSequenceFinish() {
                        activity.getSharedPreferences(Constants.GuidePrefs,Context.MODE_PRIVATE).edit().putBoolean(Constants.setting_guide_prefs,true).apply();
                    }

                    @Override
                    public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}

                    @Override
                    public void onSequenceCanceled(TapTarget lastTarget) {
                        activity.getSharedPreferences(Constants.GuidePrefs,Context.MODE_PRIVATE).edit().putBoolean(Constants.setting_guide_prefs,true).apply();
                    }
                })
                .start();
    }

and my error :

java.lang.IllegalArgumentException: Given null view to target
        at com.getkeepsafe.taptargetview.ViewTapTarget.<init>(ViewTapTarget.java:31)
        at com.getkeepsafe.taptargetview.TapTarget.forView(TapTarget.java:175)
        at ir.xrostamzadeh.physics.other.Global.showSettingGuide(Global.java:589)
        at ir.xrostamzadeh.physics.fragments.SettingFragment.onStart(SettingFragment.java:68)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:2632)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:915)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6186)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

I'll be happy if you can help

  • Hi, I think you should be more specific on your question and explain with an example and pasting the exact problem you face when you try to do it. This is just an idea. May be it helps you getting more anwers. You can edit your question and add more stuff. I hope it helps – Mike Mar 07 '20 at 12:57
  • Much better. I have no idea about your question. I was just trying to help your chances to get an answer. Make sure that your question can help any other people who step in the same mistake. In a few months you will be helping others like I'm doing now. Good luck! – Mike Mar 07 '20 at 14:00

0 Answers0