I have this code in a fragment
public class TestOne extends Fragment {
View view = null;
@Override
public void onConfigurationChanged(Configura
In onCreateView create FrameLayout - this is the container for you fragmenView. Then create your R.layout.testone and add it to frameLayout.
In onConfigurationChanged clear FrameLayout, create R.layout.testone again and add it to frameLayout.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
frameLayout = new FrameLayout(getActivity());
LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.testone, null);
frameLayout .addView(view);
return frameLayout;
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
frameLayout. removeAllViews();
LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.testone, null);
frameLayout .addView(view);
}
Now all will work as you want!