Search code examples
javaandroidandroid-fragmentsfragmentandroid-orientation

Crash after change screen fragment


I want to send data with a bundle and retrieve them in another fragment.

My problem is that the application crashes when I change the orientation of the screen in Fragment Receive.

Here is a piece of my code:

Fragment Receive :

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_actuality, container, false);

    ImageLoader imageLoader = AppController.getInstance().getImageLoader();

    ImageView networkImageView = (ImageView)view.findViewById(R.id.thumbnail);

    Bundle bundle = getArguments();

    textcontent = (TextView)view.findViewById(R.id.content);
    texttitle = (TextView)view.findViewById(R.id.title);
    textdate = (TextView)view.findViewById(R.id.date);
    textweb = (TextView)view.findViewById(R.id.web);



    textcontent.setText(Html.fromHtml(bundle.getString("article")));
    textdate.setText("le " + bundle.getString("date"));
    texttitle.setText(bundle.getString("title"));
    textweb.setText("Pour plus d'information : " + bundle.getString("urlweb")); }

Solution

  • Add this line to your activity in the manifest:

    android:configChanges="keyboardHidden|orientation|screenSize"