Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Sandro Meschiari
18,418 Pointsextra credit display info of friends in a new activity
i there i am doing the extra credit challenge from the "ribbit app" where i need to acquire extra info from the user, save them in Parse.com and then display them in a new activity, so far i managed to acquire and save new info for new profile i also created a new activity to display them but one i click on it the page is empty how can i visualise the content of it? Ben Jakuben
5 Answers
George Pirchalaishvili
3,747 PointsWell as I understand, you already got all the data about the users from query in this activity.
What I would do is create an Intent which leads to next activity (show user info one). Put extra (user info class), which contains only info about the user clicked on. Than use intent.get in user info class to get all the data you need.
Harry James
14,780 PointsI also agree with George here and think this is the best way to go about this - as you're only going to be showing one users data, you can just get the data of that user and send it off in an Intent (Or you can just pass along their username and do the get the extra data in that activity/another class).
Either way, you'll get the same result, it's just personal preference how you wish to organise it :)
George Pirchalaishvili
3,747 PointsCan you show code, which you use in you second activity to display info?
Sandro Meschiari
18,418 Pointspublic class FriendsProfileActivity extends ActionBarActivity{
public static final String TAG = FriendsProfileActivity.class.getSimpleName();
@Override
protected void onResume() {
super.onResume();
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByAscending(ParseConstant.KEY_USERNAME);
query.setLimit(10);
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> users, com.parse.ParseException e) {
if (e == null) {
}
else {
Log.e(TAG, e.getMessage());
AlertDialog.Builder builder = new AlertDialog.Builder(FriendsProfileActivity.this);
builder.setMessage(e.getMessage())
.setTitle(R.string.error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_friends_profile);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_friends_profile, menu);
return true;
}
}
//everything i tried in the if (e==null) condition failed
George Pirchalaishvili
3,747 PointsWhat if you try making code in try/catch instead of if/else
try {
} catch (e) {
Log.e(TAG, e.getMessage());
AlertDialog.Builder builder = new AlertDialog.Builder(FriendsProfileActivity.this);
builder.setMessage(e.getMessage())
.setTitle(R.string.error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
Sandro Meschiari
18,418 Pointsit is working with if/else, my problem is that i don't how to display the ParseObject
Ivan Knyazev
4,927 PointsIvan Knyazev
4,927 PointsTry this one: https://teamtreehouse.com/forum/retrieving-another-users-information-parsecom