Currently , i added HorizontalScrollView In each item of List View each HorizontalScrollView displayes the images dynamically on the basis of data fetched from the sqlite. Sqlite is preloaded with the data that is downloaded from our application server.
Also, In each list item 'Camera' button is added. On click event of this button I am adding images captured from Camera to the existing HorizontalScrollView.
1) First I'm trying to show images dynamically in HorizontalScrollView from sqlite in ArrayAdapter -
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
final Holder holder;
if (row == null) {
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
row = vi.inflate(R.layout.all_post_row, null);
holder = new Holder();
holder.imgBtn_Camera = (ImageView) row.findViewById(R.id.imgButton_Camera);
holder.imgBtn_Audio = (ImageView) row.findViewById(R.id.imgButton_RecordAudio);
holder.horizontalScrollView = (HorizontalScrollView) row.findViewById(R.id.hlist);
holder.lLinearLayout = (LinearLayout) row.findViewById(R.id.innerlay);
row.setTag(holder);
} else {
holder = (Holder) row.getTag();}
strListItem_ActivityId = all_Post.getStrActivityId();
dbhelper = new MyDbHelper(AllPosts_Page.this);
SQLiteDatabase db = dbhelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from ActivityObjectList where activityId " + "= ? ", new String[]{strListItem_ActivityId});
imageArray.clear();
if (cursor.moveToFirst()) {
do {
String imagePath = cursor.getString(cursor.getColumnIndex("imageaudioPath"));
Log.e("imagePath ", " = " + imagePath);
imageArray.add(imagePath);
}
while (cursor.moveToNext());
}
cursor.close();
db.close();
holder.lLinearLayout.removeAllViews();
final Iterator<String> it = imageArray.iterator();
while (it.hasNext()) {
LayoutInflater mInflater;
mInflater = LayoutInflater.from(getContext());
View cur_deal = mInflater.inflate(R.layout.horizontalitem, holder.lLinearLayout, false);
imageView = (ImageView) cur_deal.findViewById(R.id.image_AllPost);
pBar = (ProgressBar) cur_deal.findViewById(R.id.pBar_AllPost);
pBar.setVisibility(View.VISIBLE);
holder.lLinearLayout.addView(cur_deal);
final String imgElement = it.next();
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String path = baseDir + "/classnkk_images/" + imgElement;
Log.e("path ", " = " + path);
File photos = new File(path);
final Bitmap bitmapResizeImage = decodeFile(photos);
imageView.setImageBitmap(bitmapResizeImage);
}
2) Here is my Camera button click event in ArrayAdapter class -
holder.imgBtn_Camera.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Toast.makeText(context, "Camera" + " = ", Toast.LENGTH_SHORT).show();
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
((Activity) context).startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
3) Here is onActivityResult method implementation which is in Activity class -
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_PIC_REQUEST && resultCode == Activity.RESULT_OK)
{
{
onActivityResult(requestCode, resultCode, data);
Bitmap bp = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(bp);
}
}
}
The above code should show the images captured from camera into HorizontalScrollView. . I am not able to understand where does it went wrong ? I have tried to modify code in many ways. However it did not help.
I'm trying to solve this issue since 15 days.Please someone help me for this question.
Thanks in advanced.