I have a activity with toolbar
,Tablayout
, viewpager
with fragments
like that
I want to implement toolbar
here is your solution, I tried this in fragment.
public static void showTabLayout() {
parentTabs.setVisibility(View.VISIBLE);
}
public static void hideTabLayout() {
parentTabs.setVisibility(View.GONE);
}
public interface FragmentLifecycle {
public void onPauseFragment();
public void onResumeFragment();
}
CameraFragment.java
package demo.com.demo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by rucha on 24/11/16.
*/
public class CameraFragment extends Fragment implements FragmentLifecycle {
public CameraFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = null;
rootView = inflater.inflate(R.layout.fragment_blue,
container, false);
setupUI(rootView);
return rootView;
}
private void setupUI(View rootView) {
}
@Override
public void onPauseFragment() {
MainActivity.showTabLayout();
}
@Override
public void onResumeFragment() {
MainActivity.hideTabLayout();
}
}
I hope this is useful. Happy Coding!!