0
public void addNewImageToScreen (int resourceId)
{
    if (mLastNewCell != null) mLastNewCell.setVisibility (View.GONE);

    FrameLayout imageHolder = (FrameLayout) findViewById (R.id.image_source_frame);
    if (imageHolder != null) {
       FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams (LayoutParams.FILL_PARENT, 
                                                                   LayoutParams.FILL_PARENT, 
                                                                   Gravity.CENTER);
       ImageCell newView = new ImageCell (this);
       newView.setImageResource (resourceId);
       imageHolder.addView (newView, lp);
       newView.mEmpty = false;
       newView.mCellNumber = -1;
       mLastNewCell = newView;
       mImageCount++;

       // Have this activity listen to touch and click events for the view.
       newView.setOnClickListener(this);
       newView.setOnLongClickListener(this);
       newView.setOnTouchListener (this);

    }
}

我已经使用上面的代码在屏幕上动态生成图像。现在我想在图像单元格上添加一些文本。提前致谢。

4

1 回答 1

0

ImageCell 是一个实现 ImageView 的类,因此使用 FrameLayout 我可以在其上重叠文本谢谢@Triode

于 2013-05-10T06:06:43.747 回答