当前位置: 代码迷 >> Android >> android 怎么动态生成id
  详细解决方案

android 怎么动态生成id

热度:84   发布时间:2016-04-28 01:05:46.0
android 如何动态生成id?
android 如何动态生成id?

Button btn = new Button(getActivity());
btn.setId(xxx);
btn.setText("remove me");

如果我随意写个数,它与系统id重复怎么办?
------解决思路----------------------
与系统Id 相同会怎样不知道

自己在两个布局中定义了两个控件  用相同的ID 是没有问题的
程序运行也是没有错的
------解决思路----------------------
可以btn.setId("btn_"+时间戳); 
  相关解决方案