Sahil Grover
Sahil Grover

Reputation: 1915

How to get a slide transition in phonegap?

I have seen many questions posted over here on Stackoverflow regarding glitch/interval/gap between two html pages when using phonegap to develop an application. I have found a plugin slider plugin for phonegap. After searching a lot I am not able to figure out how to perform this step 3.

Add the import for your resource Java file (yourpackage.R) to LoadingSpinner.java

This is something which seems to me like a native code and I am not able to understand.

My questions are :

  1. What is this yourpackage.R file ??
  2. Where is it located ??
  3. And how to do that step 3 given over there ??

Thanks

-----------edit-----------

Here is the content of R.java

    package com.somethingsomething.appone;

    public final class R {
        public static final class attr {
        }
        public static final class drawable {
            public static final int ic_launcher=0x7f020000;
        }
        public static final class layout {
            public static final int main=0x7f030000;
        }
        public static final class string {
            public static final int app_name=0x7f060001;
            public static final int hello=0x7f060000;
        }
        public static final class style {
            public static final int loading_spinner=0x7f050000;
        }
        public static final class xml {
            public static final int cordova=0x7f040000;
            public static final int plugins=0x7f040001;
        }
    }

and content of LoadingSpinner.java is

    package de.sandstein.phonegap.plugin.transition;

    import android.app.Dialog;
    import android.content.Context;
    import android.view.ViewGroup.LayoutParams;
    import android.widget.ProgressBar;

    public class LoadingSpinner extends Dialog {

            public static LoadingSpinner show(Context context, CharSequence title,
                    CharSequence message) {
                return show(context, title, message, false);
            }

            public static LoadingSpinner show(Context context, CharSequence title,
                    CharSequence message, boolean indeterminate) {
                return show(context, title, message, indeterminate, false, null);
            }

            public static LoadingSpinner show(Context context, CharSequence title,
                    CharSequence message, boolean indeterminate, boolean cancelable) {
                return show(context, title, message, indeterminate, cancelable, null);
            }

            public static LoadingSpinner show(Context context, CharSequence title,
                    CharSequence message, boolean indeterminate,
                    boolean cancelable, OnCancelListener cancelListener) {
                LoadingSpinner dialog = new LoadingSpinner(context);
                dialog.setTitle(title);
                dialog.setCancelable(cancelable);
                dialog.setOnCancelListener(cancelListener);
                /* The next line will add the ProgressBar to the dialog. */
                dialog.addContentView(new ProgressBar(context), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                dialog.show();

                return dialog;
            }

            public LoadingSpinner(Context context) {
                super(context, R.style.loading_spinner);
            }
    }

Imported R.java in LoadingSpinner.java as

 import android.R;

Now the error states

loading_spinner cannot be resolved or is not a field

-----------edit-----------

replaced android.R by com.somethingsomething.appone.R in file LoadingSpinner.java as

 import com.somethingsomething.appone.R;

Still the error states

loading_spinner cannot be resolved or is not a field

Clean the project and restart eclipse and errors are gone.

Usage says

    1) Call initTransition() on startup of the app.
    2) Call showLoadingView() to show the loading view. (Android: can use parameter "animation" ('slide' oder 'fade'))
    3) When the animation has finished 'transitionAnimationReady' is fired.
    4) Call hideLoadingView() to hide the loading view.

Where can I find the place to declare these global functions so as it is applicable on all files.

Should it be in some other file, in html file above the html tag, in head tag. Tried out putting the following code above html and in head tag.

<script type="text/javascript" charset="utf-8" src="transition.js"></script>
<script type="text/javascript">
    initTransition();
    showLoadingView('slide');
    hideLoadingView();
    alert("hi");
</script>

Upvotes: 0

Views: 648

Answers (1)

Its not blank
Its not blank

Reputation: 3095

  1. I have not used phonegap however as far as android is concerned "your package".R is a system generated java file that stores a an int id unique to each and every id that you have used in your app. That includes layouts, strings values etc.

  2. Since it is system generated it is stored in gen folder of your application

  3. If you are familiar with java its just an ordinary import.

just check this ref you get a lot about R.java

Upvotes: 3

Related Questions