RLin2013 2014-12-09 04:06 采纳率: 100%
浏览 11944
已采纳

Android如何获取动态添加控件的id

 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);
  • 写回答

1条回答 默认 最新

  • liweijie_chengxuyuan 2014-12-09 05:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?