I am creating a newInstance method under Android's Activity class.
However, it will not recognize the setArgument method that accompanies the fragment. Have you seen this before?
private static final String ARG_OPTION = "argument_option";
public static MainActivity newInstance (int option){
MainActivity fragment = new MainActivity();
Bundle args = new Bundle();
args.putInt(ARG_OPTION, option);
fragment.setArgument(args);
return fragment;
}
You need to use
fragment.setArguments(args);
instead of
fragment.setArgument(args);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.