zoukankan      html  css  js  c++  java
  • fragment setArguments

    https://blog.csdn.net/tu_bingbing/article/details/24143249

    public class FramentTest2Activity extends ActionBarActivity {
           
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                 setContentView(R.layout. activity_main);
     
                  if (savedInstanceState == null) {
                        getSupportFragmentManager().beginTransaction()
                                     .add(R.id. container, TestFragment.newInstance("param")).commit();
                 }
     
           }
     
            public static class TestFragment extends Fragment {
     
                  private static final String ARG = "arg";
                 
                  public TestFragment() {
                        Log. i("INFO", "TestFragment non-parameter constructor" );
                 }
     
                  public static Fragment newInstance(String arg){
                        TestFragment fragment = new TestFragment();
                        Bundle bundle = new Bundle();
                        bundle.putString( ARG, arg);
                        fragment.setArguments(bundle);
                         return fragment;
                 }
                 
                  @Override
                  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
                        View rootView = inflater.inflate(R.layout. fragment_main, container,
                                      false);
                        TextView tv = (TextView) rootView.findViewById(R.id. tv);
                        tv.setText(getArguments().getString( ARG));
                         return rootView;
                 }
           }
     
    }
  • 相关阅读:
    最小生成树计数
    Tree
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ Physics
    NOJ Physics
    NOJ Physics
    NOJ Physics
  • 原文地址:https://www.cnblogs.com/Oldz/p/14061449.html
Copyright © 2011-2022 走看看