比如,有一個ImageView:
public ImageView get_image_by_name(String name)
{
int image_id = getResources().getIdentifier(name , "drawable", getPackageName());
return (ImageView)findViewById(image_id);
}
不知道應該怎麼添加到layout中?
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