my ImageView is always trying to re-use the same bitmap whereas whenever i tap (onTap ()) it ‘s supposed to go look for the right image not using the same. How can I prevent it to so??
besides, whenever i recycle it, my activity crshes when i tap again…
Please help!
my logcat gives me:
03-14 14:40:15.519 D/setting image>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>(29389): grrrrr java.lang.NullPointerException
here is my snippet :
protected boolean onTap(int i) {
/* Toast.makeText(getApplicationContext(),
locations.get(i).getSnippet() + " " + locations.get(i).getTitle(),
Toast.LENGTH_SHORT).show();*/
// mapView = (MapView) findViewById(R.id.mapView);
OverlayItem item=getItem(i);
GeoPoint geo=item.getPoint();
Bitmap bitmap = null;
Point pro= mapView.getProjection().toPixels(geo, null);
if (pro!=null)
{ View view=panel.getView();
/* }
catch (Exception e){Log.d("merde>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", "grrrrr " +e);}*/
String capteur= getType (locations.get(i).getSnippet());
((TextView)view.findViewById(R.id.poptext))
.setText(String.valueOf("image captured by : " + capteur + "\n" + "Latitude = " + locations.get(i).getPoint().getLatitudeE6() +" " + "Longitude = "+ locations.get(i).getPoint().getLongitudeE6() +" " +
"\n" + "Image can be found at the following directory :" + locations.get(i).getTitle()
));
if (locations.get(i).getTitle()!=null){
try {
bitmap = BitmapFactory.decodeFile(locations.get(i).getTitle());} catch (Exception e){Log.d("getting Title>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", "grrrrr " +e.getMessage());}
if (bitmap!=null){
try{
mContext=getApplicationContext ();
((ImageView) findViewById(R.id.ImageV)).setImageBitmap(bitmap);
} catch (Exception e){Log.d("setting image>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", "grrrrr " +e);}}
else {}
}else {}
panel.show(true
);}
return(true);
}
my popup panel
class PopupPanel {
Context mContext= getApplicationContext();
View popup;
boolean isVisible=false;
PopupPanel(int layout) {
ViewGroup parent=(ViewGroup)mapView.getParent();
popup=getLayoutInflater().inflate(layout, parent, false);
popup.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
hide();
}
});
}
View getView() {
return(popup);
}
void show(boolean alignTop) {
RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
if (alignTop) {
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
lp.setMargins(20, 20, 20, 20);
}
else {
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lp.setMargins(20, 20, 20, 60);
}
hide();
((ViewGroup)mapView.getParent()).addView(popup, lp);
isVisible=true;
}
void hide() {
if (isVisible) {
isVisible=false;
((ViewGroup)popup.getParent()).removeView(popup);
}
}
one thing I can tell you right away is that e.getMessage() doesn’t really works. It’ll return null and you’ll get null pointer exception.
update
well, i can tell you that too,
when you call that and say
The view R.id.ImageV is inflated someplace else and what you are getting here is just an raw ref. to that view. You need to have referece to the actual view which originally inflated that view and then through that view you can call
that’ll definately solve your problem.