LoginSignup
0
0

More than 5 years have passed since last update.

fragmentのパラメーター

Last updated at Posted at 2015-10-03

fragment(パラメーター付き)生成

public static HogeFragment createInstance(String hoge)
HogeFragment fragment = new Hogeframent;
Bundle args = new Bundle();
bundle.putString("key",hoge);
fragment.setArgument(bundle);
return  fragment

パラメーター取得

パラメーターの取得はonCreateメソッドなどでgetArgumentメソッドを使用して取得するといいらしいので

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(saveInstanceState)

    Bundle bundle = getArguments();

    String type = bundle.getString("key")

}

参考

Y.A.M の 雑記帳

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0