如何在Android中创建使用XML的GUI呢? [英] How to create GUI in Android instead of using XML?
本文介绍了如何在Android中创建使用XML的GUI呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不喜欢管理 XML
和的Java
在一起,我可以创建一个使用相同的图形用户界面的Java
语言?
我如何能做到这一点,你可以告诉我,code简单按钮
?
我将AP preciate正确的答案。
I don't like to manage XML
and Java
together, can I create same GUI using Java
language?
How can I do that, can you tell me code for simple Button
?
I will appreciate the proper answer.
推荐答案
是的,你可以。
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Button button = new Button(this);
button.setText("Press me!");
setContentView(button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
}
}
这篇关于如何在Android中创建使用XML的GUI呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文