如何在Android中显示UpComing Facebook好友生日

时间:2013-02-15 05:03:25

标签: android facebook android-facebook

我正在编写一个应用程序,我将以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

0 个答案:

没有答案