RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.relaGameZhaiGuoZi);
imgApple2 = new ImageView(this);
imgApple2.setImageResource(R.drawable.app);
imgApple2.setId(110);
imgApple2.setOnClickListener(this);
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp1.leftMargin=30;
lp1.topMargin = 100;
mainLayout.addView(imgApple2,lp1);
Android如何获取动态添加控件的id
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-