Спасибо за ответ.Я нашел другой способ для этого: использовать GridView и класс ImageAdapter.Для интересующихся:
public class ImageAdapter extends BaseAdapter {
private Context mContext;
private int unlocked=10;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return 20;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(90, 50));
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
} else {
imageView = (ImageView) convertView;
}
if(position<unlocked){
imageView.setImageResource(R.drawable.gheta_med);
}else{
imageView.setImageResource(R.drawable.gheta_med_lock);
}
return imageView;
}
и в моей деятельности
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
Log.i("item", ""+arg2);