getarguments().getstring updates android

https://w‮l.ww‬autturi.com
getarguments().getstring updates android

In an Android app, you can use the getArguments() method of a Fragment to get the arguments passed to the fragment when it was created. The getArguments() method returns a Bundle object, which is a mapping of keys to values.

To get a String value from the Bundle, you can use the getString() method of the Bundle class. Here's an example of how you could use these methods to get a String argument passed to a fragment:

import android.os.Bundle;
import androidx.fragment.app.Fragment;

public class MyFragment extends Fragment {
  private String myArgument;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myArgument = getArguments().getString("my_argument");
  }
}

In this example, the myArgument field will be initialized with the value of the my_argument key in the Bundle.

To pass arguments to a fragment, you can use the setArguments() method of the Fragment class.

Created Time:2017-11-01 12:04:59  Author:lautturi