ListView不显示来自JSON的数据

时间:2014-06-05 07:57:56

标签: android facebook listview adapter

我是Android新手,我正在制作一个facebook应用程序,但似乎我的适配器没有正确设置数据。这是代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_feed);

    textView = (TextView) findViewById(R.id.message);
    author = (TextView) findViewById(R.id.author);
    listView = (ListView) findViewById(R.id.list);
    feedList = new ArrayList<HashMap<String, String>>();
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);


    // -------------------------------------------------------------------------------------



    Session.NewPermissionsRequest np = new Session.NewPermissionsRequest(
            this, "read_stream");
    Session.getActiveSession().requestNewReadPermissions(np);
    Request rq = new Request(Session.getActiveSession(), "me/home", null,
            HttpMethod.GET, new Request.Callback() {

                @Override
                public void onCompleted(Response response) {
                    Log.i("RESPONSEEEE", response.toString());

                    try {
                        GraphObject graphObj = response.getGraphObject();
                        JSONObject json = graphObj.getInnerJSONObject();
                        JSONArray jArray = json.getJSONArray("data");
                        for (int i = 0; i < jArray.length(); i++) {
                            JSONObject currObj = jArray.getJSONObject(i);
                            final String userId = currObj.getString("id");
                            if (currObj.has("message")) {
                                userMessage = currObj.getString("message");
                            } else if(currObj.has("story")){
                                userMessage = currObj.getString("story");
                            } else{
                                userMessage = "no message/story set";
                            }
                            JSONObject fromObj = currObj
                                    .getJSONObject("from");
                            String from = fromObj.getString("name");

                            HashMap<String, String> feed = new HashMap<String, String>();
                            feed.put(TAG_ID, userId);
                            feed.put(TAG_MESSAGE, userMessage);
                            feed.put(TAG_NAME, from);

                            feedList.add(feed);
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            });
    rq.executeAsync();

    BaseAdapter adapter = new SimpleAdapter(feeders.this, feedList,
            R.layout.list, new String[] { TAG_MESSAGE, TAG_NAME,
                    TAG_ID }, new int[] { R.id.message, R.id.author,
                    R.id.id_tv });
    listView.setAdapter(adapter);

     adapter.notifyDataSetChanged();

运行代码后,我使用 Log 查看JSON,我得到了它,问题是当我设置适配器时。没有任何错误。我希望你能帮助我。谢天谢天。

这里是logcat的详细信息:

 06-05 08:01:06.071: E/ActivityThread(1883): Failed to find provider info for com.facebook.katana.provider.PlatformProvider
06-05 08:01:06.071: E/ActivityThread(1883): Failed to find provider info for com.facebook.wakizashi.provider.PlatformProvider
06-05 08:01:06.201: E/ActivityThread(1883): Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
06-05 08:01:06.502: W/EGL_emulation(1883): eglSurfaceAttrib not implemented
06-05 08:01:06.581: W/EGL_emulation(1883): eglSurfaceAttrib not implemented
06-05 08:01:06.591: D/FacebookSDK.WebDialog(1883): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth?return_scopes=true&response_type=token&scope=read_stream&redirect_uri=fbconnect%3A%2F%2Fsuccess&auth_type=rerequest&display=touch&e2e=%7B%22init%22%3A1401955266086%7D&client_id=289929124509967&access_token=CAAEHsGJ5ZBQ8BACvCv8u4OoZBjLSsBw3y8iJEPuu5odf4f6SV7ZAhvi7k5RRCadLqO6zfHqO3ADjZC6bHSX4keJQXTrUQit3lketxcxmHNZASS50dBwEXZAtOrtCfqQkuFZCwuC5E87uXF9lAZAZCLUWTMoPIUA5tksKEZBmG1jPWZAplenddhbQrRqEsrBtZCC1wmdhrtwkZAikgWFTbQfHZBGVjUo7xVAS3BK10ZD
06-05 08:01:07.180: W/EGL_emulation(1883): eglSurfaceAttrib not implemented
06-05 08:01:13.841: D/dalvikvm(1883): GC_CONCURRENT freed 1308K, 25% free 21574K/28716K, paused 80ms+112ms, total 275ms
06-05 08:01:13.841: D/webviewglue(1883): nativeDestroy view: 0x2a313f30
06-05 08:01:14.051: I/RESPONSEEEE(1883): {Response:  responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[{"id":"10203184247080483_10203356147177389","story":"Graciela Guevara and Ros Ann Rivera like a photo.","likes":{"data":[{"id":"10203184247080483","name":"Graciela Guevara"},{"id":"854775894535878","name":"Ros Ann Rivera"},{"id":"10203990825917154","name":"Jason Mitchell Bautista"},{"id":"778275728859408","name":"Bernadette Ong"},{"id":"845973315432275","name":"Tey Tey"},{"id":"10201068825083259","name":"Mikee Bañares"},{"id":"10202172205972641","name":"Anne Pelias-Lin"}],"paging":{"cursors":{"after":"MTAyMDIxNzIyMDU5NzI2NDE=","before":"MTAyMDMxODQyNDcwODA0ODM="}}},"privacy":{"value":""},"story_tags":{"21":[{"length":14,"id":"854775894535878","type":"user","offset":21,"name":"Ros Ann Rivera"}],"0":[{"length":16,"id":"10203184247080483","type":"user","offset":0,"name":"Graciela Guevara"}]},"from":{"id":"10203184247080483","name":"Graciela Guevara"},"created_time":"2014-06-05T07:48:24+0000","type":"status","updated_time":"2014-06-05T07:48:24+0000","actions":[{"link":"https:\/\/www.facebook.com\/1637112559\/posts\/10203356147177389","name":"Comment"}]},{"icon":"https:\/\/fbstatic-a.akamaihd.net\/rsrc.php\/v2\/yz\/r\/StEh3RhPvjk.gif","application":{"id":"2305272732","name":"Photos"},"object_id":"335556923259002","link":"https:\/\/www.facebook.com\/326521344162560\/photos\/at.326528720828489.1073741828.326521344162560.100001204631870\/335556923259002\/?type=1&relevant_count=1","privacy":{"value":""},"story_tags":{"27":[{"length":54,"id":"326521344162560","type":"page","offset":27,"name":"Optrimax plum delite lose weight w\/o deit and exercise"}],"0":[{"length":12,"id":"740929252623889","type":"user","offset":0,"name":"Lhea VaLerio"}]},"from":{"id":"740929252623889","name":"Lhea VaLerio"},"type":"photo","updated_time":"2014-06-05T07:46:05+0000","picture":"https:\/\/fbcdn-photos-a-a.akamaihd.net\/hphotos-ak-xfp1\/t1.0-0\/10390175_335556923259002_996565313826746313_s.jpg","id":"740929252623889_744090888974392","story":"Lhea VaLerio was tagged in Optrimax plum delite lose weight w\/o deit and exercise's photo.","status_type":"tagged_in_photo","description":"After 9 pieces (9 nights) of OpTRIMax Plum Delite..\nFrom 60.5 kg to 55.5 kg!!\nFrom 133.10 lbs to 122.10 lbs!!\n\nThank you plum delite! \n\nFeel lighter. Live healthier. \n\nJust 1 plum a day,\nAnd loose 5-10 kgs in 10 days.\n\nOrder now! \n09061724549\n\nADD ME ON FACEBOOK: https:\/\/www.facebook.com\/jherome.santos.3","created_time":"2014-06-05T07:46:05+0000","actions":[{"link":"https:\/\/www.facebook.com\/100001204631870\/posts\/744090888974392","name":"Comment"},{"link":"https:\/\/www.facebook.com\/100001204631870\/posts\/744090888974392","name":"Like"}]},{"to":{"data":[{"id":"264530327066096","name":"Joshmico Lupaz"},{"id":"873411582687952","name":"Jesue Capili Lupaz"},{"id":"894051677276575","name":"Julie Balatero Lupaz"}]},"icon":"https:\/\/fbstatic-a.akamaihd.net\/rsrc.php\/v2\/yx\/r\/og8V99JVf8G.gif","application":{"id":"350685531728","namespace":"fbandroid","name":"Facebook for Android"},"message_tags":{"5":[{"length":8,"id":"264530327066096","offset":5,"type":"user","name":"Joshmico"}]},"object_id":"10201712891896620","link":"https:\/\/www.facebook.com\/photo.php?fbid=10201712891896620&set=pcb.10201712892336631&type=1&relevant_count=2","privacy":{"value":""},"from":{"id":"10201685882301397","name":"Anine Capili Lupaz"},"type":"photo","updated_time":"2014-06-05T07:45:55+0000","picture":"https:\/\/fbcdn-photos-h-a.akamaihd.net\/hphotos-ak-xpf1\/v\/t34.0-11\/10423601_10201712889216553_776562913_s.jpg?oh=9b6d442400704b848ef9dd70199e84b8&oe=53923603&__gda__=1402072247_3404f1024a4a40e533e92e9c6c330019","message":"Kuya Joshmico","id":"10201685882301397_10201712892336631","with_tags":{"data":[{"id":"873411582687952","name":"Jesue Capili Lupaz"},{"id":"894051677276575","name":"Julie Balatero Lupaz"}]},"status_type":"mobile_status_update","created_time":"2014-06-05T07:45:55+0000","actions":[{"link":"https:\/\/www.facebook.com\/1610027080\/p
06-05 08:01:20.771: D/FacebookSDK.WebDialog(1883): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth/confirm
06-05 08:01:20.932: W/EGL_emulation(1883): eglSurfaceAttrib not implemented
06-05 08:01:21.611: D/FacebookSDK.WebDialog(1883): Redirect URL: fbconnect://success#granted_scopes=public_profile%2Cread_stream%2Cread_mailbox%2Crsvp_event%2Cemail%2Ccontact_email%2Cread_insights%2Cmanage_notifications%2Cread_friendlists%2Cmanage_pages%2Cpublish_actions%2Cuser_birthday%2Cuser_religion_politics%2Cuser_relationships%2Cuser_relationship_details%2Cuser_hometown%2Cuser_location%2Cuser_likes%2Cuser_activities%2Cuser_interests%2Cuser_education_history%2Cuser_work_history%2Cuser_website%2Cuser_groups%2Cuser_events%2Cuser_photos%2Cuser_videos%2Cuser_about_me%2Cuser_status&denied_scopes=&access_token=CAAEHsGJ5ZBQ8BAOkdFP883FDZB99ZCOd8Unim6a7xt0hslH2KBNy4KkM1QfYkSiTOCWvSO1AttGA6GYBaBuZCdnxQZCmZCsFWow9eVgJmgOKj5V79rkdL5mWlSL5lTzk8AxjXabcYrIaZBmhWpIS4c4rnB3MxZBgbWvs2tdLNsTXRx3hZBOSUqs5PA9jDJXk0bHwt6xjc2bVkfo7esgmH1blMwWAw1MZBDiugZD&expires_in=5166342
06-05 08:01:23.471: D/dalvikvm(1883): GC_CONCURRENT freed 2516K, 27% free 20983K/28716K, paused 120ms+109ms, total 325ms  

0 个答案:

没有答案
相关问题