ADT blank activity created with fragment activity..

后端 未结 15 2026
鱼传尺愫
鱼传尺愫 2020-11-28 05:55

i am really confused right now because whenever i create a new android app with blank activity it always comes out with fragment_main.xml.. i just wanted to create a blank a

15条回答
  •  不知归路
    2020-11-28 06:10

    Not sure if this works completely, Steps 1) Right click on your project goto properties->Android, remove reference library and press apply. now you would see errors in your project go to res->values->styles, replace AppBasetheme's parent by parent="android:Theme.Light" do this for all values folder except in values_v14 there put parent="android:Theme.Holo.Light.DarkActionBar"

    2) Now goto MainActivity replace "extends ActionBarActivity" by "extends Activity". Eclipse will prompt you to import for activity do it.

    now delete this part of code

    public static class PlaceholderFragment extends Fragment {
    
        public PlaceholderFragment() {
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);
            return rootView;
        }
    }
    

    from activity class

    if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    

    Now remove all unused imports.

    3) Goto res->Layouts->fragment.xml, copy code of fragment into activity_main.xml. Delete fragment.xml.

    Now goto main.xml Replace this

        
    

    by

        
    

    4) Now Click on Project and clean your project

提交回复
热议问题