Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 java 代码中以编程方式添加一个按钮,而不是从 XML 文件中添加它。我怎样才能做到这一点?
第一步是在 onStart() 中实例化按钮,稍后将实例化的按钮添加到 ComponentContainer 或 setUIContent();
@Override protected void onStart(Intent intent) { super.onStart(intent); Button button = new Button(MainAbilitySlice.this); setUIContent(button); }