Adding ImageButton top of another one in android - android

I'm making a gallery in my application. I listed my images successfully and now adding its share buttons. Instead of directing user into another form, I'm trying to show share buttons above my image. For listing and sharing I need to create and add dynamic ImageButtons. But when I try to add share buttons, they're shown in wrong place. Here is my code:
LinearLayout ll = (LinearLayout) findViewById(R.id.llGallery);
for (int i = 0; i < jsonArray.length(); i++) {
final JSONObject jsonObject = jsonArray.getJSONObject(i);
final String Photo= jsonObject.getString("PhotoLink");
// PhotoDetails into another view
View.OnClickListener cPhotoDetails= new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(GalleryDetailsActivity.this,
GalleryPhotoDetails.class);
intent.putExtra("Image", Photo);
startActivity(intent);
}
};
View.OnClickListener cShare= new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
File myFile = new File(fotograf);
MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext = myFile.getName().substring(myFile.getName().lastIndexOf(".") + 1);
String type = mime.getMimeTypeFromExtension(ext);
Intent sharingIntent = new Intent("android.intent.action.SEND");
sharingIntent.setType(type);
sharingIntent.putExtra("android.intent.extra.STREAM", Uri.fromFile(myFile));
startActivity(Intent.createChooser(sharingIntent, "Share with"));
} catch (Exception e) {
// Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
};
RelativeLayout rel = new RelativeLayout(context);
rel.setGravity(Gravity.CENTER_VERTICAL);
ImageButton img = new ImageButton(context);
img.setClickable(true);
img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
Glide.with(context).load(Photo).into(img);
img.setOnClickListener(cPhotoDetails);
rel.addView(img);
ImageButton share = new ImageButton(context);
share.setClickable(true);
share.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(R.drawable.btn_share).into(share);
share.setOnClickListener(cShare);
rel.addView(share);
ll.addView(rel);
}

RelativeLayout rel = new RelativeLayout(context);
rel.setGravity(Gravity.CENTER_VERTICAL);
ImageView img = new ImageView(context);
img.setClickable(true);
img.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(Photo).into(img);
img.setOnClickListener(cPhotoDetails);
rel.addView(img);
ImageButton share = new ImageButton(context);
share.setClickable(true);
share.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(R.drawable.btn_share).into(share);
share.setOnClickListener(cShare);
rel.addView(share);
ll.addView(rel);

Related

share the current image viewflipper

I want to share the current image being viewed from the viewflipper, but I can not get the name of the image being displayed, this is the code I use:
public class imagen1 extends Activity {
public float init_x;
private ViewFlipper vf;
int gallery_grid_Images[] = {R.drawable.fondo, R.drawable.fondo2, R.drawable.fondo3,
R.drawable.fondo4, R.drawable.fondo5
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.imagen1);
ImageView imagePreview = (ImageView) findViewById(R.id.preview);
vf = (ViewFlipper) findViewById(R.id.viewFlipper);
for (int i = 0; i < gallery_grid_Images.length; i++) {
// This will create dynamic image view and add them to ViewFlipper
setFlipperImage(gallery_grid_Images[i]);
}
vf.setOnTouchListener(new ListenerTouchViewFlipper());
}
private void setFlipperImage(int res) {
Log.i("Set Filpper Called", res + "");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
vf.addView(image);
}
public void compartir (View v) {
Uri newUri2 = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + gallery_grid_Images);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "");
shareIntent.putExtra(Intent.EXTRA_STREAM, newUri2);
shareIntent.setType("image/jpg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "Compartir"));
}
}
If someone could help me a little would greatly appreciate it
Probably this should do the trick for you:
public class imagen1 extends Activity {
public float init_x;
private ViewFlipper vf;
int gallery_grid_Images[] = {R.drawable.fondo, R.drawable.fondo2, R.drawable.fondo3,
R.drawable.fondo4, R.drawable.fondo5
};
ImageView[] views = new ImageView[gallery_grid_Images.length];
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.imagen1);
ImageView imagePreview = (ImageView) findViewById(R.id.preview);
vf = (ViewFlipper) findViewById(R.id.viewFlipper);
for (int i = 0; i < gallery_grid_Images.length; i++) {
// This will create dynamic image view and add them to ViewFlipper
setFlipperImage(gallery_grid_Images[i], i);
}
vf.setOnTouchListener(new ListenerTouchViewFlipper());
}
private void setFlipperImage(int res, int index) {
Log.i("Set Filpper Called", res + "");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
vf.addView(image);
views[index] = image;
}
public void compartir (View v) {
int index = -1;
for (int i = 0; i < views.length; i++) {
if (views[i] == (ImageView) vf.getCurrentView())
index = i;
}
if (index == -1) {
// failed to determine the right index
Log.w("imagen1", "Could not determine the right index!");
return;
}
Uri newUri2 = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + gallery_grid_Images[index]);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "");
shareIntent.putExtra(Intent.EXTRA_STREAM, newUri2);
shareIntent.setType("image/jpg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "Compartir"));
}
}
I've used it just a few times, but as far as I know the viewflipper just show one of its childs at a time. You should call this method in order to show a child:
viewFlipper.setDisplayedChild(childPosition);
The loop in your code will just set the last image of your array, if you'd rather to show a list of images you should go for a RecyclerView/ListView.
Hope this helps!
works perfectly, you do not know how much I appreciate your help, I only had to modify a part in the code because it gave me error:
Uri newUri2 = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + gallery_grid_Images[i]);
add Index
Uri newUri2 = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + gallery_grid_Images[index]);
Thank you so much for your help

How do I sort the buttons generated from the following code alphabetically base on string values

<string name="Manuf0">best</string>
<string name="Manuf1">Bravo</string>
<string name="Manuf2">zoo</string>
<string name="Manuf3">Skitz</string>
<string name="Manuf4">don</string>
<string name="Manuf5">animal</string>
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
scrollviewManuf = new ScrollView(this);
LinearLayout linearlayout = new LinearLayout(this);
linearlayout.setOrientation(LinearLayout.VERTICAL);
scrollviewManuf.addView(linearlayout);
for (int i = 0; i < 5; i++)
{
LinearLayout linearManuf = new LinearLayout(this);
linearManuf.setOrientation(LinearLayout.HORIZONTAL);
linearlayout.addView(linearManuf);
Manufb = new Button(this);
int id = getResources().getIdentifier("Manuf" + i, "string", getPackageName());
String Manuf = getResources().getString(id);
Manufb.setText(Manuf);
Manufb.setId(i);
Manufb.setTextSize(30);
Manufb.setPadding(0, 0, 0, 0);
// b.setTypeface(Typeface.SERIF,Typeface.ITALIC);
Manufb.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
linearManuf.addView(Manufb);
Manufb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
String SManuf= Manuf.replaceAll("&","").replaceAll(" ","").replaceAll("/","").replaceAll(" / ","").replaceAll("/ ","").replaceAll(" /","".replaceAll("&",""));
//Panel= getResources().getString(id);
Toast.makeText(getApplicationContext(), SManuf , Toast.LENGTH_SHORT).show();
Intent passIntent = new Intent(Manufacturers.this,panels.class);
passIntent.putExtra("SManuf",SManuf);
startActivity(passIntent);
}
});
}
this.setContentView(scrollviewManuf);
}
}
How do I sort the buttons generated from the following code alphabetically base on string values.
Currently they are listed as the buttons are produced 0 through to 5.
The list is in an xml string file, want to eb alphabetical so I can just add more to the file as needs be, and the programming just sort it alphabetically which suits me.
Not been able to find anything yet , but I am gueesing I may need to define the list in the file and sort that list can anyone point me in the right direction please.
Okay, so I can see the code is doing something but the sort order isn't changing and the String s is showing up in intellij as not used, : new code below:-
marked the sections with // here
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayList<String> theStrings = new ArrayList<>();//Here
scrollviewManuf = new ScrollView(this);
LinearLayout linearlayout = new LinearLayout(this);
linearlayout.setOrientation(LinearLayout.VERTICAL);
scrollviewManuf.addView(linearlayout);
for (int i = 0; i < 28; i++) {
LinearLayout linearManuf = new LinearLayout(this);
linearManuf.setOrientation(LinearLayout.HORIZONTAL);
linearlayout.addView(linearManuf);
Manufb = new Button(this);
int id = getResources().getIdentifier("Manuf" + i, "string", getPackageName());
String Manuf = getResources().getString(id);
theStrings.add(Manuf); /// Here
Manufb.setText(Manuf);
Manufb.setId(i);
Manufb.setTextSize(30);
Manufb.setPadding(0, 0, 0, 0);
// b.setTypeface(Typeface.SERIF,Typeface.ITALIC);
Manufb.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
linearManuf.addView(Manufb);
Manufb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String PManuf =Manuf;
// TODO Auto-generated method stub
String SManuf= Manuf.replaceAll("&","").replaceAll(" ","").replaceAll("/","").replaceAll(" / ","").replaceAll("/ ","").replaceAll(" /","".replaceAll("&",""));
//Panel= getResources().getString(id);
Toast.makeText(getApplicationContext(), Manuf+" Selected" , Toast.LENGTH_SHORT).show();
Intent passIntent = new Intent(Manufacturers.this,panels.class);
passIntent.putExtra("SManuf",SManuf);
passIntent.putExtra("PManuf",PManuf);
startActivity(passIntent);
}
} );
} Collections.sort(theStrings); //here
for (String s : theStrings) { //here
//...
this.setContentView(scrollviewManuf); }//here
}
}
The following code is looping each time it loops its adding an extra repeated option.
ie. Cat,dog,mouse, donkey correct list is the list but I am getting, Cat, dog.dog, mouse,mouse,mouse, donkey, donkey, donkey,donkey but still no sorting, still working on it but here is the code.
ArrayList<String> theStrings = new ArrayList<>();
for (int i = 0; i < 28; i++) {
int id = getResources().getIdentifier("Manuf" + i, "string", getPackageName());
String Manuf = getResources().getString(id);
theStrings.add(Manuf);
Collections.sort(theStrings);
for (String s : theStrings) {
LinearLayout linearManuf = new LinearLayout(this);
linearManuf.setOrientation(LinearLayout.HORIZONTAL);
linearlayout.addView(linearManuf);
Manufb = new Button(this);
Manufb.setText(Manuf);
Manufb.setId(i);
Manufb.setTextSize(30);
Manufb.setPadding(0, 0, 0, 0);
// b.setTypeface(Typeface.SERIF,Typeface.ITALIC);
Manufb.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
linearManuf.addView(Manufb);
Manufb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String PManuf = Manuf;
// TODO Auto-generated method stub
String SManuf = Manuf.replaceAll("&", "").replaceAll(" ", "").replaceAll("/", "").replaceAll(" / ", "").replaceAll("/ ", "").replaceAll(" /", "".replaceAll("&", ""));
//Panel= getResources().getString(id);
Toast.makeText(getApplicationContext(), Manuf + " Selected", Toast.LENGTH_SHORT).show();
Intent passIntent = new Intent(Manufacturers.this, panels.class);
passIntent.putExtra("SManuf", SManuf);
passIntent.putExtra("PManuf", PManuf);
startActivity(passIntent);
}
});
}
}
this.setContentView(scrollviewManuf);
}
}
Read it into a list, sort it and loop over it:
ArrayList<String> theStrings = new ArrayList<>();
for (int i = 0; i < 28; i++) {
int id = getResources().getIdentifier("Manuf" + i, "string", getPackageName());
String Manuf = getResources().getString(id);
theStrings.add(Manuf);
}
Collections.sort(theStrings);
for (String s : theStrings) {
LinearLayout linearManuf = new LinearLayout(this);
linearManuf.setOrientation(LinearLayout.HORIZONTAL);
linearlayout.addView(linearManuf);
Manufb = new Button(this);
Manufb.setText(s); // <-- use the String here
Manufb.setId(i);
Manufb.setTextSize(30);
Manufb.setPadding(0, 0, 0, 0);
// b.setTypeface(Typeface.SERIF,Typeface.ITALIC);
Manufb.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
linearManuf.addView(Manufb);
...

how to set text under programatically created dynamic imagebutton in android

I am creating a application where I need to add imagebutton dynamatically,
under that imagebutton I want to set some text. I tried bellow posted code but I am getting exception at L.addView(btn);
Plz suggest something......
for (int i = 1; i <= SplashScreenActivity.num; i++)
{
LinearLayout L = new LinearLayout(this);
LayoutParams params_1 = new LayoutParams(241,137);
params_1.width=(int)(scaleX*241);
params_1.height=(int)(scaleY*137);
L.setLayoutParams(params_1);
ImageButton btn = new ImageButton(this);
File file= new File(Environment.getExternalStoragePublicDirectory("Android/data") + "/" + getApplicationContext().getPackageName()+"/CoverImages/skc_"+i+".jpg");
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
btn.setImageBitmap(bm);
btn.setScaleType(ScaleType.FIT_XY);
btn.setBackgroundColor(80000000);
btn.setId(i);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(241, 137);
layoutParams.width=(int)(scaleX*241);
layoutParams.height=(int)(scaleY*137);
layoutParams.setMargins(24, 0, 24, 0);
ll.addView(btn, layoutParams);
TextView tv = new TextView(this);
tv.setGravity(Gravity.BOTTOM);
tv.setTextColor(Color.BLUE);
name = "purchased";
tv.setId(i);
tv.setText(name);
L.setOrientation(LinearLayout.HORIZONTAL);
btn.setMaxWidth(mButtonWidth);
btn.setMaxHeight(mButtonHeight);
L.addView(btn);
L.addView(tv);
ll .addView(L);
final int id_ = btn.getId();
btn = ((ImageButton) findViewById(id_));
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view)
{
utils.playTapSound();
File myDirectory = new File(Environment.getExternalStoragePublicDirectory("Android/data") + "/" + getApplicationContext().getPackageName() + "/ComicBook/comic"+MainPage.get_id+"/skc"+MainPage.get_id+".zip");
if(myDirectory.exists())
{
Intent intent = new Intent(MainPage.this,
FullScreenViewActivity.class);
startActivityForResult(intent, 0);
}
else
{
startService(new Intent(getApplicationContext(), BillingService.class));
Intent intent = new Intent(MainPage.this,InAppActivity.class);
startActivityForResult(intent, 0);
}
}
});

EditText array of existing EditTexts won't be declared right

I am creating an app, in which I create some EditTexts dynamically with ID number.
I want to pass the information from the EditTexts, so I tried to create a EditText array with these and then use the .getText().toString() to save them in a String Array, which I want pass to the next activity.
It seems like it won't create the "editArray[]" in second code part correctly.
Thanks in advance.
Here's my code (EnterNames.java) - Creation of EditTexts -> Succesful
protected void NumberOfEditText()
{
View VertLayout = (LinearLayout) findViewById(R.id.VertLayout);
String SpinValue = getIntent().getExtras().getString("SpinValue");
int intSpinValue = Integer.valueOf(SpinValue);
editTextCount = intSpinValue;
EditText[] editTextArray = new EditText[editTextCount];
for (int i = 0; i < editTextCount; i++)
{
String Name = "Name " + (i+1);
editTextArray[i] = new EditText(this);
editTextArray[i].setId(i+1000);
editTextArray[i].setText(Name);
editTextArray[i].setTextSize(20);
editTextArray[i].setFilters( new InputFilter[] { new InputFilter.LengthFilter(15) } );
editTextArray[i].setSelectAllOnFocus(true);
editTextArray[i].setSingleLine(true);
editTextArray[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
((LinearLayout) VertLayout).addView(editTextArray[i]);
}
}
Second code (EnterNames.java) - Passing data to next activity -> Failure.
By testing I think the problem is the for-loops (the editArray returns null)
public void Go(View view)
{
setContentView(R.layout.activity_enter_names);
String NameArray [] = new String [editTextCount];
EditText editArray [] = new EditText [editTextCount];
Intent intent = new Intent(this, RandomGeneration.class);
for (int i = 0; i < editTextCount; i++)
{
editArray[i] = (EditText) findViewById(i+1000);
}
for (int i = 0; i < editTextCount; i++)
{
NameArray[i] = editArray[i].getText().toString();
}
Bundle extras = new Bundle();
extras.putInt("NumberofNames", editTextCount);
extras.putStringArray("NameArray", NameArray);
intent.putExtras(extras);
startActivity(intent);
}
According to Activity.findViewById() documentation, this method will search for views in your XML, not in views added in Java.
The simple way to do what you want:
class EnterNames extends Activity {
private int editTextCount;
private EditText[] editTextArray;
protected void NumberOfEditText() {
LinearLayout vertLayout = (LinearLayout) findViewById(R.id.VertLayout);
editTextCount = Integer.valueOf(getIntent().getExtras().getString("SpinValue"));
editTextArray = new EditText[editTextCount];
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
for (int i = 0; i < editTextCount; i++) {
String Name = "Name " + (i+1);
editTextArray[i] = new EditText(this);
editTextArray[i].setText(Name);
editTextArray[i].setTextSize(20);
editTextArray[i].setFilters( new InputFilter[] { new InputFilter.LengthFilter(15) } );
editTextArray[i].setSelectAllOnFocus(true);
editTextArray[i].setSingleLine(true);
editTextArray[i].setLayoutParams(params);
vertLayout.addView(editTextArray[i]);
}
}
[…]
public void Go(View view)
{
// This will delete views added to your LinearLayout, don't use it!
//setContentView(R.layout.activity_enter_names);
String nameArray[] = new String[editTextCount];
for (int i = 0; i < editTextCount; i++) {
nameArray[i] = editArray[i].getText().toString();
}
Bundle extras = new Bundle();
extras.putInt("NumberofNames", editTextCount);
extras.putStringArray("NameArray", nameArray);
Intent intent = new Intent(this, RandomGeneration.class);
intent.putExtras(extras);
startActivity(intent);
}
}
Why you are calling setContentView(R.layout.activity_enter_names); in public void Go(View view)? You overide Activities layout in which you previously has added EditText views and all your findById() returns null.
Your code should work if you remove setContentView(R.layout.activity_enter_names); from Go function.
setContentView(R.layout.activity_enter_names); should be called single time in Activities onCreate function.

Android : Load image from specific directory

I have a gallery that is displaying thumbnail images in custom directories. The gallery displays fine, but I am unable to open the full image by clicking the thumbnail. My [non functioning] click listener is below
try {
if (LoadImageFiles() == true) {
GridView imgGallery = (GridView) findViewById(R.id.gallery);
final ImageAdapter ia = new ImageAdapter(PersonMedia.this);
imgGallery.setAdapter(ia);
// Set up a click listener
imgGallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
String imgPath = paths.get(position);
Intent intent = new Intent(getApplicationContext(), ViewImage.class);
intent.putExtra("filename", imgPath);
startActivity(intent);
}
});
}
} catch (Exception ex) {
Log.e("PersonMedia.LoadPictures", ex.getMessage());
}
Here is how the gallery is populated
//Declare a module level hashtable
private Hashtable<Integer, String> paths;
private boolean LoadImageFiles() {
try{
mySDCardImages = new Vector<ImageView>();
paths = new Hashtable<Integer, String>();
fileCount = 0;
sdDir = new File(imageDirectory);
sdDir.mkdir();
if (sdDir.listFiles() != null)
{
File[] sdDirFiles = sdDir.listFiles();
if (sdDirFiles.length > 0)
{
for (File singleFile : sdDirFiles)
{
Bitmap bmap = decodeFile(singleFile);
BitmapDrawable pic = new BitmapDrawable(bmap);
ImageView myImageView = new ImageView(PersonMedia.this);
myImageView.setImageDrawable(pic);
myImageView.setId(mediaCount);
paths.put(fileCount, singleFile.getAbsolutePath());
mySDCardImages.add(myImageView);
mediaCount++;
fileCount ++;
}
}
}
}
catch(Exception ex){ Log.e("LoadImageFiles", ex.getMessage()); }
return (fileCount > 0);
}
I was able to resolve this by using a hashtable to store the position and path of the images when the thumbnails are loaded. Below are the 2 pertinent code snippets
//Where the gallery is populated and the onclick is defined
private void PopulateGallery() {
try {
if (LoadImageFiles() == true) {
GridView imgGallery = (GridView) findViewById(R.id.gallery);
imgGallery.setAdapter(new ImageAdapter(PersonMedia.this));
// Set up a click listener
imgGallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
String imgPath = paths.get(position);
Intent intent = new Intent(getApplicationContext(), ViewImage.class);
intent.putExtra("filename", imgPath);
startActivity(intent);
}
});
}
} catch (Exception ex) {
Log.e("PersonMedia.LoadPictures", ex.getMessage());
}
}
//Where the images are loaded. You'll need to create a module level hashtable
private Hashtable<Integer, String> paths;
private boolean LoadImageFiles() {
try{
mySDCardImages = new Vector<ImageView>();
paths = new Hashtable<Integer, String>();
fileCount = 0;
sdDir = new File(imageDirectory);
sdDir.mkdir();
if (sdDir.listFiles() != null)
{
File[] sdDirFiles = sdDir.listFiles();
if (sdDirFiles.length > 0)
{
for (File singleFile : sdDirFiles)
{
Bitmap bmap = decodeFile(singleFile);
BitmapDrawable pic = new BitmapDrawable(bmap);
ImageView myImageView = new ImageView(PersonMedia.this);
myImageView.setImageDrawable(pic);
myImageView.setId(mediaCount);
paths.put(fileCount, singleFile.getAbsolutePath());
mySDCardImages.add(myImageView);
mediaCount++;
fileCount ++;
}
}
}
}
catch(Exception ex){ Log.e("LoadImageFiles", ex.getMessage()); }
return (fileCount > 0);
}
Do your images have extensions, such as .jpg or .png? I'm not quite sure but it looks like you are looking for an image that is string version of your personId, without any file extension.
Please correct me if I'm wrong.
Also please post more details, such as the errors you are getting.
Updated answer below.
Use View.setTag(Object), when you are adding items to your ListView (I am guessing). You can call something like the following.
view.setTag("imgFile.jpg");
And then from inside of your onClickListener, just do this:
String img = (String) getTag();

Categories

Resources