android: how to change layout on button click?

前端 未结 8 1375
醉话见心
醉话见心 2020-12-05 00:35

I have to following code for selecting layout on button click.

View.OnClickListener handler = new View.OnClickListener(){
    public void onClick(View v) {

         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 01:10

    I would add an android:onClick to the layout and then change the layout in the activity.

    So in the layout

    
    

    Then in the activity add the following:

    public void changelayout(View view){
        setContentView(R.layout.second_layout);
    }
    

提交回复
热议问题