Start a new topic

client recognistion, setOnClickListener not working twice inside thread

client recognistion, setOnClickListener not working twice inside thread


hello wikitude

I am using wikitude sdk for android. I am using client recognition part. on recognising some image

i am showing a view with images and a cancel image on right top of the screen. please see the  attached image.

on clicking cancel button, app must go back for client recognition. first time it works smoothly ,but second time setonclicklistener 

for cancel image not working. although my issue is not specifically related with wikitude ar, but i hope you can help me on this.

thank you

 

runOnUiThread(new Runnable() {
@Override
public void run() {
if (targetName_.toString().equalsIgnoreCase("TargetOne")) {
Toast.makeText(getApplicationContext(),"tracking",Toast.LENGTH_SHORT).show();
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
LinearLayout controls = (LinearLayout) inflater.inflate(R.layout.one_video_gallery, null);
viewHolder.addView(controls);

info_one_video_gallery = (TextView)findViewById(R.id.info_one_video_gallery);
monument_name_one_video_gallery = (TextView)findViewById(R.id.monument_name_one_video_gallery);
one_video_gallary_imageview = (ImageView)findViewById(R.id.one_video_gallary_imageview);
one_video_gallary_thumbnail = (ImageView)findViewById(R.id.one_video_gallary_thumbnail);
final ImageView cancel_video_image_view= (ImageView)findViewById(R.id.cancel_video_image_view);
cancel_video_image_view.setClickable(true);


one_video_gallary_imageview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplication(),MediaFullScreenImageActivity.class);
String monument_images = PropertyFile.TargetOne + "_images";
intent.putExtra("monument_images",monument_images);
startActivity(intent);
}
});

one_video_gallary_thumbnail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), MediaVideoActivity.class);
String monument = PropertyFile.TargetOne;
intent.putExtra("monument", monument);
String monument_images = PropertyFile.TargetOne + "_images";
intent.putExtra("monument_images", monument_images);
startActivity(intent);
}
});


if(cancel_video_image_view.getVisibility() == View.INVISIBLE){
cancel_video_image_view.setVisibility(View.VISIBLE);
cancel_video_image_view.setClickable(true);
one_video_gallary_imageview.setVisibility(View.VISIBLE);
one_video_gallary_thumbnail.setVisibility(View.VISIBLE);
info_one_video_gallery.setVisibility(View.VISIBLE);
monument_name_one_video_gallery.setVisibility(View.VISIBLE);

}

//issue - this method is not invoked for the second time
cancel_video_image_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "You clicked the button", Toast.LENGTH_SHORT).show();
one_video_gallary_imageview.setVisibility(View.INVISIBLE);
one_video_gallary_thumbnail.setVisibility(View.INVISIBLE);
cancel_video_image_view.setVisibility(View.INVISIBLE);
info_one_video_gallery.setVisibility(View.INVISIBLE);
monument_name_one_video_gallery.setVisibility(View.INVISIBLE);
}
});


 

Hi Mithun Kumar,

is it only the cancel button which doesn't work or is it the other imageViews as well?
If it is only the cancel button my guess would be that you could declare the cancel_video_image_view as member like you did with the other imageViews. This way the ImageView and with it the onClickListener should still exist after you leave the runnable.

Best regards
Alex

 

Hi Alex.

Thank you for taking your time to look on this issue. Only cancel image not working, other images working fine and I tried exactly same way as you explained in the post, but it is also not working. as for now i am refreshing(restarting) the screen, it works but user will notice that screen is recreating. can you let me know if there is any another way to solve this. 

thank you

mithun kumar

Hi Mithun Kumar,

you could also try moving

info_one_video_gallery = (TextView)findViewById(R.id.info_one_video_gallery);
monument_name_one_video_gallery = (TextView)findViewById(R.id.monument_name_one_video_gallery);
one_video_gallary_imageview = (ImageView)findViewById(R.id.one_video_gallary_imageview);
one_video_gallary_thumbnail = (ImageView)findViewById(R.id.one_video_gallary_thumbnail);
final ImageView cancel_video_image_view= (ImageView)findViewById(R.id.cancel_video_image_view);

outside of targetRecognized since they probably wont't change if a target is recognized.

Best regards
Alex

Hi Alex,

thank you for your valuable suggestion.

with regards

mithun kumar
Login or Signup to post a comment