Android: programmatically adding buttons to a layout

前端 未结 5 2092
梦如初夏
梦如初夏 2020-11-29 07:40

I\'m trying to get an add button to add another button to the layout, based on the edittext to the left of the button. The point is for a person to list the rooms in their

5条回答
  •  囚心锁ツ
    2020-11-29 08:14

    Each button needs to have an onclicklistener to tell it what to do. this can be added to your java code under where you state your button.

    Button createdButton = new Button(this);
    createdButton.setOnClickListener(new OnClickListener()
    {
    
    code you want implemented
    
    }
    

提交回复
热议问题