I am currently making a part of my app to select multiple images from gallery using Gridview. The PROBLEM is that I need to put a button on the first item and the rest will be images (the 0,0 will be button and the rest well, imageview with check box) That button will be using the phone camera. I was able to make it, but in exchange, it is not scrolling smoothly, is there a way to fix this? below is my code:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
View view;
System.out.println(position);
if (position == 0) {
holder = new ViewHolder();
view = getLayoutInflater().inflate(R.layout.year_dropdownlayout, parent, false);
holder.mButton = (Button) view.findViewById(R.id.mfreakingBtn);
ViewGroup.LayoutParams params = holder.mButton.getLayoutParams();
params.height = 250;
params.width = 250;
holder.mButton.requestLayout();
} else {
view = getLayoutInflater().inflate(R.layout.select_photos_layout, parent, false);
holder = new ViewHolder();
holder.imageView = (ImageView) view.findViewById(R.id.imageView1);
holder.mCheckBox = (CheckBox) view.findViewById(R.id.checkBox1);
holder.mCheckBox.setOnCheckedChangeListener(mCheckedChangeListener);
holder.progressBar = (ProgressBar) view.findViewById(R.id.progress);
holder.mButton = null;
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "You Clicked " + position, Toast.LENGTH_LONG).show();
}
});
imageLoader.displayImage("file://" + imageUrls.get(position), holder.imageView, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
holder.progressBar.setProgress(0);
holder.progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
holder.progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
Animation anim = AnimationUtils.loadAnimation(MultiPhotoSelect.this, R.anim.fade_in);
holder.imageView.setAnimation(anim);
anim.start();
holder.progressBar.setVisibility(View.GONE);
}
}, new ImageLoadingProgressListener() {
@Override
public void onProgressUpdate(String imageUri, View view, int current,
int total) {
holder.progressBar.setProgress(Math.round(100.0f * current / total));
}
}
);
holder.mCheckBox.setTag(position);
holder.mCheckBox.setChecked(mSparseBooleanArray.get(position));
}
return view;
}
Don't mind the names of the layouts. :) This what happens when frustration gets to ya. I have been looking for hours now. I found one who put a button on the end of the gridview this: Android - Different items in GridView not showing up
I hope someone can help me. Thanks in advance. :)
0 comments:
Post a Comment