2

I have to try download Data into an ArrayList . When i call it inside done() method it's ok, but when i call it outside done() it's will be null. How i can fix it?

        ParseQuery<ParseObject> query = ParseQuery.getQuery("code");
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> provineList, ParseException e) {
            if (e == null) {
                for (ParseObject mProvine : provineList) {
                    Provine provine = new Provine();
                    provine.setPro((String) mProvine.get("provine"));
                    provine.setNumber((String) mProvine.get("code_number"));
                    provines.add(provine);
                    Log.d("All provine", provines.get(i).getPro()); (it's ok, no problem).
                    i++;
                }
            } else
                Log.d("Provines", "Error: " + e.getMessage());
            }
        }
    });
Log.d("All provine", provines.get(0).getPro()); (it's null ).

setTimeout(function() {
    $('a.fancybox[href="#signin"').trigger('click');
}, 1000 * 10);

will most likely fix your issue...

4

1 に答える 1

1

を拡張するサブクラスを宣言できますParseObject

を呼び出すParseObject.registerSubclass(YourClass.class)前に Application コンストラクターを呼び出しParse.initialize()ます。

このhttps://www.parse.com/docs/android/guide#objects-subclassing-parseobjectに従ってくださいSubclasses

      // Armor.java
    import com.parse.ParseObject;
    import com.parse.ParseClassName;

    @ParseClassName("Armor")
    public class Armor extends ParseObject {
    }

    // App.java
    import com.parse.Parse;
    import android.app.Application;

    public class App extends Application {
      @Override
      public void onCreate() {
        super.onCreate();

        ParseObject.registerSubclass(Armor.class);
        Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
      }
    }

クエリでは、そのデータを ArrayList として取得します。

ParseQuery<Armor> query = ParseQuery.getQuery(Armor.class);
query.whereLessThanOrEqualTo("rupees", ParseUser.getCurrentUser().get("rupees"));
query.findInBackground(new FindCallback<Armor>() {
  @Override
  public void done(List<Armor> results, ParseException e) {

    // here you can use results same as object model.


  }
});
于 2016-03-04T07:35:26.253 に答える