I have two views in my Android application (2 view fragments actually). The first view has a textfield and a button, the 2nd view has a ListView.
What i want to do is set some data in the ListView, based on what is set in the textfield (from the first view). But i'm not sure how to do this.
I'm currently setting hardcoded data in the ListView from the onCreateView
method in the 2nd Views SecondFragment.java file. Which looks something like this:
ListView list = (ListView)view.findViewById(R.id.list_mainmenu);
items.add(new SectionItem("Section 1"));
items.add(new EntryItem("Item 1", "This is item 1", 1));
items.add(new EntryItem("Item 2", "This is item 2", 2));
items.add(new EntryItem("Item 3", "This is item 3", 3));
EntryAdapter adapter = new EntryAdapter(this.getActivity().getBaseContext(), items);
list.setAdapter(adapter);
But having that in the onCreateView
method isn't what i want. I want to be able to set that list for that view from another java file. In my case FirstFragment.java
.
Is this possible, and if so, how can i do that?
I can imagine that there must already be some instance of the SecondFragment.java
class, because the onCreateView
is immidiately called when the app loads. I just can't find out where i can get it from.