0

i've been trying to figure this out all day. I have a Query list from stackMob that is supposed to give me the latest 10 obj I created in a list I think. I don't really understand how this stuff works. I made a layout with a listview and I want to use that list to populate the listview. How do I do that? I've tried over 10 different ways and nothing works. I then tried to println this list in the console but that's not doing anything either.

public void QueryWritter() {

    StackTask.query(StackTask.class, new StackMobQuery().isInRange(0, 9),
            new StackMobQueryCallback<StackTask>() {

                ListView queryTwo = (ListView) findViewById(R.id.objectreader_two);
                TextView queryOne = (TextView) findViewById(R.id.objectreader);

                @Override
                public void failure(StackMobException e) {
                    // TODO Auto-generated method stub
                    e.printStackTrace();
                }

                @Override
                public void success(List<StackTask> task) {
                    // TODO Auto-generated method stub

                    //task = new ArrayList<StackTask>();
                    //ArrayAdapter<StackTask> a = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, task);
                    System.out.println(task);



                }

            });

}

Thanks in advance!

Jason Cheladyn
  • 565
  • 1
  • 12
  • 24

1 Answers1

1

Nothing you're doing looks wrong. Do see anything printed from either callback?

The next step in debugging this would be to enable logging, which you can do by adding this line in your onCreate StackMob.getStackMob().getSession().getLogger().setLogging(true); That will print out what's actually going over the network so you can see what's getting called. I can take a look at the output if it doesn't clear things up immediately

Douglas Rapp
  • 360
  • 2
  • 5
  • It's working! I see the list now in the log, but do you know how I can populate my listView with the list data? I've tried so many ways and I don't know how to do it. Thanks a lot! – Jason Cheladyn Jan 24 '13 at 19:12
  • You need to use a handler to modify the UI. Try using something like this final ArrayAdapter data = new ArrayAdapter(AndroidTestActivity.this, listItem, respDataStrings); final ListView list = (ListView) findViewById(R.id.listView1); mHandler.post(new Runnable() { public void run() { list.setAdapter(data); } }); – Douglas Rapp Jan 29 '13 at 19:09
  • What is respDataStrings and mHandler? What am I supposed to do with that? – Jason Cheladyn Jan 30 '13 at 15:52
  • Here's a better link http://crodrigues.com/updating-the-ui-from-a-background-thread-on-android/ – Douglas Rapp Feb 11 '13 at 19:07