`
咖啡动力
  • 浏览: 435331 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics