Android Studio Blank Activity

后端 未结 6 1138
遇见更好的自我
遇见更好的自我 2021-01-15 02:25

I\'m using Android Studio 2.1 and there is no Blank Activity option. I\'ve seen people asking about this, and the general advice was \"make one yourself\". The thing is tha

相关标签:
6条回答
  • 2021-01-15 02:35

    Select File --> Settings

    Select "Plugins" from that window

    1.) Android NDK Support 2.) Android Support

    check there any Tick Mark. Make Tick mark them, if no tick Marked . Then Rebuild Your App. or Close android studio and reopen

    0 讨论(0)
  • 2021-01-15 02:37

    Empty Activity is the same as Blank Activity. It will gives you .xml file that will be your layout where you put your Buttons or EditTexts and .java file where you will code your activity.
    But Basic Activity will gives you two .xml files, the main_activity.xml that contain FloatingActionButton and a ToolBar and it will include the second .xml where you will put your Buttons and one .java file .
    If you are new at android developing start with Empty Activity it's more simple to understand

    0 讨论(0)
  • 2021-01-15 02:38

    Basic Activity comes with FloatingActionButton and menu layout. Empty Activity does not contain FloatingActionButton and menu xml layout, although you can add them manually when you feel so. What I feel is that Basic Activity is preferable because when you created Empty Activity and want to add menu in your activity it become rather difficult to add menu xml layout manually. I have personally encounter problems while adding menu xml manually.

    0 讨论(0)
  • 2021-01-15 02:40

    If you want to keep things in line with what they do there, you should go with Basic Activity because in the third step of that tutorial you'll need content_my.xml which won't be generated if you choose Empty Activity at start (of course you can put your code in activity_main.xml which is pretty the same thing). So if you only want to go in line with the tutorial you choose Basic Activity. The difference between previous Blank Activity and current Basic Activity is the extra code generated in your activity like:

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    
    0 讨论(0)
  • 2021-01-15 02:47

    I had the same question so I've compared the old blank activity template (according to a video tutorial I watched) with the 'empty' and the 'basic' activities templates of the new Android Studio.

    The empty activity has only 2 options: "Activity Name" and "Layout Name".

    Meanwhile Basic activity has 4 options, just like the "blank activity" template of the old Android Studio version as you can see below:

    So, I would go with the basic template and manage the extra code until I need it.

    0 讨论(0)
  • 2021-01-15 03:00

    If you go with BaseActivity, it is also kind of empty activity. It would have only a root element in its layout. So you can start with any of the Basic or Empty.

    0 讨论(0)
提交回复
热议问题