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.
CodePudding user response:
I would have the adapter method expect an argument like below:
fun getComment(photoId : String) {
// then pass the photoId 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.