0

我想从 java 代码中以编程方式添加一个按钮,而不是从 XML 文件中添加它。我怎样才能做到这一点?

4

1 回答 1

0

第一步是在 onStart() 中实例化按钮,稍后将实例化的按钮添加到 ComponentContainer 或 setUIContent();

 @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        Button button = new Button(MainAbilitySlice.this);
        setUIContent(button);
    }
于 2021-07-30T09:55:18.583 回答