2012-04-16 33 views
0

我看到了很多关于使用Phonegap开发应用程序时在Stackoverflow上发布的关于两个html页面之间的小故障/间隔/间隙的问题。我找到了一个用于phonegap的插件slider plugin。搜索了很多之后,我无法弄清楚如何执行该步骤3.如何获得手机中的幻灯片切换?

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

这是一些东西,在我看来,像一个原生代码,我无法理解。

我的问题是:

  1. 这是什么yourpackage.R文件?
  2. 它在哪里?
  3. 以及如何做到那里给出的第3步?

感谢

----------- -----------编辑

这里是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; 
     } 
    } 

和LoadingSpinner.java的含量是

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); 
      } 
    } 

进口R.java在LoadingSpinner.java作为

import android.R; 

现在的错误状态

loading_spinner cannot be resolved or is not a field 

----------- ---------编辑 -

文件LoadingSpinner.java取代android.R通过com.somethingsomething.appone.R作为

import com.somethingsomething.appone.R; 

仍然错误状态

loading_spinner cannot be resolved or is not a field 

清理项目并重新启动eclipse,错误消失。

用法说

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. 

我在哪里可以找到这些声明的全局函数,以便它适用于所有文件的地方。

它应该在其他文件中,在html标记上方的html文件中,在头标记中。试过把下面的代码放在html和head标签中。

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

回答

3
  1. 我没有使用过的PhoneGap但是至于Android是关注“你的包” .R是存储唯一一个一个int id来每一个ID,您已经使用了系统生成的Java文件在你的应用程序。这包括布局,字符串值等。

  2. 因为它是系统生成它存储在您的应用程序

  3. 的根文件夹,如果你熟悉Java的只是一个普通的进口。

只是检查这个ref你得到了很多关于R.java

+0

“进口com.somethingsomething.appone.R;”因为你在做什么会使用android的默认R.java。 – 2012-04-16 13:31:00

+0

这个插件可以用于phonegap 2.2.0 – Udo 2014-03-17 06:55:47