读书人

android从xml创造控件(按钮)或直接创

发布时间: 2012-08-14 10:39:58 作者: rapoo

android从xml创建控件(按钮)或直接创建控件
android从xml创建控件

根据xml创建view (res/layout 这个文件夹中的play_cartoon_exit.xml)
View viewxml=getLayoutInflater().inflate(R.layout.play_cartoon_exit,null);

xml中有个id为button的Button
private Button button=(Button)findViewById(R.id.button)



直接创建控件
直接创建view
继承View的自定义view
public class ComicLivePlayerView extends View{
}

final ComicLivePlayerView view = new ComicLivePlayerView(this);

直接创建button
Button btnJump = new Button(this);

读书人网 >XML SOAP

热点推荐