I want to invoke a (tabbed)fragment method to bring the data to activity.
- I read this
- But I get null object reference
- I tried this
- But my activity is already implementing the fragment class so it's not a legal expression
So when the tab is changed I want the form of the first tab to send to details to Activity by getDetails()
method
@Override
public void onTabUnselected(TabLayout.Tab tab) {
if (tab.getText().equals("Owner")) {
//invoking method here
Log.i(TAG, tab.getText().toString() + " unselected");
}
I tried with FragmentManager but no luck, Please help!
EDIT- This is the method I want to invoke
public Bundle getData() {
Bundle bundle = new Bundle();
bundle.putString("area", area);
bundle.putString("villageTown", villageTown.getSelectedItem().toString());
bundle.putString("ownerName", ownerName);
bundle.putString("fatherHusbandName", fatherHusbandName);
bundle.putString("category", category.getSelectedItem().toString());
bundle.putString("address", address);
bundle.putString("mobileNumber", mobileNumber);
bundle.putString("telephoneNumber", telephoneNumber);
return bundle;
}