Answer the question
In order to leave comments, you need to log in
How to access fragment adapter from activity?
How to refer to the adapter located in the fragment from the activity?
In MainActivity I send data to the fragment:
myCardFragment = new MyCardFragment();
myCardFragment.updateAdapter(newText);
public void updateAdapter(String strSearch){
if(myCardsAdapter != null){
myCardsAdapter.filter(strSearch);
}
}
Answer the question
In order to leave comments, you need to log in
Comrade gim0 suggested:
//...Some code here;
private MyCardsAdapter myCardsAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_view, container, false);
myCardsAdapter = new MyCardsAdapter();
// Some code here...;
return view;
}
new Object;
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question