在我输入另一个活动并返回

时间:2016-01-25 00:14:08

标签: android gridview

我有一个GridView和2项,当我进入应用程序时只显示一个项目,但如果我在应用程序中输入活动并返回,它显示第二项,我不知道是什么问题。

CustomGrid:

public class CustomGrid extends BaseAdapter
{
private final int[] Imageid;
private Context mContext;
private final String[] web;

public CustomGrid(Context paramContext, String[] paramArrayOfString, int[] paramArrayOfInt1)
{
    this.mContext = paramContext;
    this.Imageid = paramArrayOfInt1;
    this.web = paramArrayOfString;
}

public int getCount()
{
    return this.web.length;
}

public Object getItem(int paramInt)
{
    return null;
}

public long getItemId(int paramInt)
{
    return 0L;
}

public View getView(int paramInt, View view, ViewGroup paramViewGroup)
{
    if (view == null)
    {
        view = View.inflate(mContext, R.layout.grid_single, null);
    }
    else
    {
        TextView Text = (TextView)view.findViewById(R.id.grid_text);
        ImageView localImageView = (ImageView)view.findViewById(R.id.grid_image);
        Text.setText(this.web[paramInt]);
        localImageView.setImageResource(this.Imageid[paramInt]);
    }
    return view;
}
}

MainActivity:

        CustomGrid localCustomGrid = new CustomGrid(this, this.web, this.imageId);
    this.grid = ((GridView)findViewById(R.id.grid));
    this.grid.setAdapter(localCustomGrid);

0 个答案:

没有答案