Facebookの友達のリストをプロフィール写真、名前、dobとともに取得するアプリを書いています。
しかし、私の友人の何人かは誕生日の日付を与えていないので、誕生日の代わりにデフォルトでnullを取得していますが、nullの代わりに表示したい:BirthdayNotMentioned。
以下の既存のアプリのスクリーンショットを参照してください。
Like:Vikas RanaはFacebookでDOBを提供し、AJay11月はFacebookでDOBを提供していません
> VikY
January 1
> AJamber
Null
ここで、Nullの代わりに表示したい:誕生日は言及されていません
FriendsList.java:
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("");
}
try {
friendItem.friendName.setText(jsonObject.getString("name"));
if(!friendItem.friendDob.equals(""))
{
friendItem.friendDob.setText(jsonObject.getString("birthday"));
}
else
{
friendItem.friendDob.setText("Birthday Not Mentioned");
}
} catch (JSONException e) {
friendItem.friendName.setText("");
friendItem.friendDob.setText("");
}
listofshit.put(position, friendItem);
return convertView;
}
そして私がこのようなコードを書いているなら:
try {
friendItem.friendName.setText(jsonObject.getString("name"));
friendItem.friendDob.setText(jsonObject.getString("birthday"));
} catch (JSONException e) {
friendItem.friendName.setText("");
friendItem.friendDob.setText("");
}
finally
{
friendItem.friendDob.setText("Birthday Not Mentioned");
}
だから私はすべてのFacebookの友達の誕生日に言及されていない誕生日を取得しています。