Multiple Activities Single Layout

2019-08-07 09:17发布

I have many activities that do the same thing overall. Is it possible to have them use the same layout? I tried using the code below, but the layout would be shifted way to left to the point where buttons would be off the screen.

setContentView(R.layout.activity_enter_pin);

TextView SecondEP = (TextView) findViewById(R.id.EnterPin);
SecondEP.setText("Enter NEW Pin");

1条回答
你好瞎i
2楼-- · 2019-08-07 10:09

There shouldn't be any problem with that, but if you are using the same layout to do the same thing in different Activity instances, you may want to look into setting up your doodad as a Fragment so it can be reused in both Activitys.

See the Android Fragments Developer Guide for more information.

查看更多
登录 后发表回答