Issue
I don't know why I'm blanking on this... but I've got a java activity which displays comments... and I need to pass the id of the photo that's being commented onto the adapter that gets all of the comments. The adapter is called CommentGrabber:
commentGrabber = new CommentGrabber(this);
...and it's executed like this:
private void requestComment() {
commentGrabber.getComment();
}
The "id" variable of the current photo can be had at any time by getting its intent but I've saved it to a string called "photo_id."
final String photo_id = getIntent().getStringExtra("id");
This is what the adapter side looks like:
fun getComment(String photo_id) {
//this is where the function is handled
}
So I just need to figure out how to get the "photo_id" from my comment activity to "getComment" in the adapter.
Solution
I would have the adapter method expect an argument like below:
fun getComment(photo_id : String) {
// from there then pass the photo_id to the service call
}
You would then call it like so:
adapter.getComment(photo_id);
Whenever you want to fetch comments by id.
I hope this makes sense. If you need further clarification, please do not hesitate to ask.
Answered By - Eenvincible
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.