I got a MainActivity and it has 3 fragments. One of those fragments got one TextView. How Can I manipulate that TextView from MainActivity?
On my MainActivity I have a TabLayout with that 3 fragments. I got data from database in MainActivity and I would like to change the textview that is on fragment 1 with that data I got.
Thank you.
I am suggest you to create some method in one of your Fragment example : In Fragment One create/ add this method :
public void Test(String jajal_disek) {
Toast.makeText(getActivity().getApplicationContext(), jajal_disek,Toast.LENGTH_SHORT).show();
ABC.setText(jajal_disek); //example your textview name ABC
}
and then in MainActivity call that's method inside FragmentOne like this :
FragmentOne fragment = (FragmentOne) getSupportFragmentManager().findFragmentById(R.id.container_body);
fragment.Test("StackOverFlow");
Hope this will help you, be great if you write source code to identified problems
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.