imageview と textview でギャラリー ウィジェットを使用しています。galleryview の setonitemclicklistener はできますが、imageview の clicklistener を設定したいです。設定しようとすると、galleryview のスクロールが機能しません。
public class AddImgAdp extends BaseAdapter {
int GalItemBg;
private Context cont;
private String[] mImageURLs = {
"http://www.example1.com",
"http://www.example2.com",
"http://www.example3.com",
"http://www.example4.com",
"http://www.example5.com",
"http://www.example6.com"
};
public AddImgAdp(Context c) {
cont = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg = typArray.getResourceId(
R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount() {
return Imgid.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
//final ViewHolder holder;
LayoutInflater li = getLayoutInflater();
View v = li.inflate(R.layout.menusliderinflate, null);
v.setPadding(15, 0, 15, 0);
int score = getLevelScore(position + 1);
Adpimgview = (ImageView) v.findViewById(R.id.level4image);
TextView scoreView = (TextView) v.findViewById(R.id.level4score);
RelativeLayout holder=(RelativeLayout)v.findViewById(R.id.FrameLayout01);
if (score > 0) {
scoreView.setText(score + "/18");
Adpimgview.setBackgroundColor(Color.parseColor("#FAAE67"));
} else {
scoreView.setVisibility(View.GONE);
if(position!=0)Adpimgview.setAlpha(100);
}
Adpimgview.setImageResource(Imgid[position]);
Adpimgview.setTag(mImageURLs[position]);
Log.d("dd","Inside adapter" + mImageURLs[position]);
Adpimgview.setScaleType(ImageView.ScaleType.FIT_XY);
// imgView.setLayoutParams(new
// Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
// LayoutParams.WRAP_CONTENT));
ここで onclicklistener を imageview に設定します
Adpimgview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
WorldSelected = position + 1;
Log.d("dd","world selected"+WorldSelected);
levelLayout.setVisibility(View.VISIBLE);
outerLayout.setBackgroundResource(R.drawable.levelbackground);
worldLayout.setVisibility(View.GONE);
backmenulayout.setVisibility(View.VISIBLE);
defaultmenulayout.setVisibility(View.GONE);
updateScore(position + 1);
onWorldItemClick();
}
});
// imgView.setBackgroundResource(GalItemBg);
return v;
}
galleryview で膨らませた imageview に onitemclicklistener を設定すると、 Galleryview のスクロールが機能しません