2012-04-16 118 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