2

我正在编写一个应用程序,我在其中以 1 月到 12 月的形式获取朋友列表,如屏幕截图所示

现在我想通过使用当前日期以即将到来的 Facebook 朋友生日的形式显示...请有人帮助我...

如下图所示,您可以看到我的朋友排在首位,那些生日已经消失,但我仍然排在首位,所以我只想以即将到来的生日的形式显示列表

       public View getView(int position, View convertView, ViewGroup parent) 
    {
        JSONObject jsonObject = null;
        try 
        {
            jsonObject = jsonArray.getJSONObject(position);
        } catch (JSONException e) {

        }

        FriendItem friendItem;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.listfb_friends, null);
            friendItem = new FriendItem();
            convertView.setTag(friendItem);
        } else 
        {
            friendItem = (FriendItem) convertView.getTag();
        }

        friendItem.friendPicture = (ImageView) convertView
                .findViewById(R.id.picture);
        friendItem.friendName = (TextView) convertView
                .findViewById(R.id.name);
        friendItem.friendDob = (TextView) convertView
                .findViewById(R.id.dob);
        friendItem.friendLayout = (RelativeLayout) convertView
                .findViewById(R.id.friend_item);

        try 
        {
            String uid = jsonObject.getString("uid");
            String url = jsonObject.getString("pic_square");
            friendItem.friendPicture.setImageBitmap(picturesGatherer.getPicture(uid, url));
        } catch (JSONException e) 
        {
            friendItem.friendName.setText("");
            friendItem.friendDob.setText("Birthday Not Mentioned");
        }

        try 
        {
            friendItem.friendName.setText(jsonObject.getString("name"));
            friendItem.friendDob.setText(jsonObject.getString("birthday"));

            if(!(jsonObject.getString("birthday").equalsIgnoreCase("null")))
            {
            friendItem.friendDob.setText(jsonObject.getString("birthday"));
            }
            else
            {
            friendItem.friendDob.setText("Birthday Not Added");
            }

        } catch (JSONException e) 
        {
            friendItem.friendName.setText("");
            friendItem.friendDob.setText("");
        }
        listofshit.put(position, friendItem);
        return convertView;
    }

查询获取记录:

    String query = "SELECT name, birthday, uid, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me())AND birthday_date >= '01/01' AND birthday_date <= '31/12' ORDER BY birthday_date";

您可以在这里找到原始代码:

https://github.com/chrtatu/FacebookFriendsList
4

0 回答 0