Android App Development for Beginners - 28 - Communicating with Main Activity

thenewboston · 189K views · 2014 · 7:12

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering how a fragment should pass data to or call methods on its parent activity.

Recommended by 2 people across 2 different months, 2015 to 2016.

What it is

A short beginner Android tutorial from thenewboston's Android App Development series, episode 28. It shows how a fragment can communicate with its host activity by defining and implementing an interface.

What people said

Recommends S bruce · 2015-12 · Stack Overflow · on “Nested RecyclerView inside ViewPager inside Fragment not affecting CoordinatorLayout”

You'll need to create an interface object that can communicate between the fragment in the recycler view and the main activity. Check this video out on how to create such interface in a slightly different use case but I think it might help because it helped me solve slightly similar problem to yours: [this video] Cheers!

Recommends Konstantinos Michael · 2016-02 · Stack Overflow · on “How to call Activity methods from inside a Fragment”

The correct way of communicating is through an interface [LINK] . Check out this video [this video] for getting the job done. The whole series worth the while if you are new to Android development.

Cites user3818576 · 2016-10 · Stack Overflow · on “How to pass value in fragment?”

I'm new in android. I'm trying to follow the tutorial from these videos link [this video] . I know there are a lot of tutorial and the same issue of mine here, but I want to know the exact reason why my app stop when I click the submit button. Sorry I'm not yet familiar with their functions in android studio and how the system work. I try to create 2 fragment, the top and the bottom fragment. In top fragment there is a submit form. When I click the submit button. The value will show to the bottom fragment. It's like passing value to another fragment. I create a fragment class name TopSectionFragment package com.example.aldrin.fragmenttutorial; import android.content.Context; import android.suppor