我正在尝试通过使用位于屏幕右上方的交叉图像(代码中的cancel_video_image_view)来关闭视图,如图像demo image中所示。它是第一次工作,但第二次无法工作,为什么设置点击监听器在运行线程内第二次不工作?请帮助: demo image 这是代码
@Override
public void onTargetRecognized(final Tracker tracker_, final String targetName_) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (targetName_.toString().equalsIgnoreCase("TargetOne")) {
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);
}
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);
}
});
}
答案 0 :(得分:0)
我认为你不应该在runOnUiThread中放置onClickListener。因为当调用onTargetRecongnized时,它只会在短时间内检查语句是否只是完成了runnable。