Android Studio Blank Activity

后端 未结 6 1139
遇见更好的自我
遇见更好的自我 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: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();
            }
        });
    

提交回复
热议问题