2 sachinks SachinKS 于 2013.03.06 16:48 提问

java如何添加一个新object到layout中

比如,有一个ImageView:

public ImageView get_image_by_name(String name)
{
    int image_id = getResources().getIdentifier(name , "drawable", getPackageName());
    return (ImageView)findViewById(image_id);
}

不知道应该怎么添加到layout中?

1个回答

lvxingang
lvxingang   2013.03.06 17:12
已采纳
 public void addView (View child)

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
child the child view to add

Csdn user default icon
上传中...
上传图片
插入图片