我有六个图像.如果我按第一个图像,则表示意图正常.但是,如果我先按第三张图像,则它不起作用.它工作正常.
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); ImageVIEw imageVIEw = (ImageVIEw) findVIEwByID(R.ID.indoor_activitIEs); imageVIEw.bringToFront(); imageVIEw.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent myIntent = new Intent (MainActivity.this,indoorActivitIEs.class); startActivity(myIntent); ImageVIEw imageVIEw = (ImageVIEw) findVIEwByID(R.ID.outdoor_activitIEs); imageVIEw.bringToFront(); imageVIEw.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent myIntent = new Intent(MainActivity.this, outdoorActivitIEs.class); startActivity(myIntent);
解决方法:
您正在R.ID.indoor_activitIEs中设置其他视图单击侦听器
在上面的代码中,您说的是,如果用户首先单击Indoor_activitIEs,则每次将click监听器分配给outdoor_activitIEs.
要解决这个问题
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); ImageVIEw imageVIEw = (ImageVIEw) findVIEwByID(R.ID.indoor_activitIEs); imageVIEw.bringToFront(); imageVIEw.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent myIntent = new Intent (MainActivity.this,indoorActivitIEs.class); startActivity(myIntent);});// click Listener for indoor activitIEs// click Listener for outdoor activitIEs when onCreated is called ImageVIEw imageVIEw = (ImageVIEw) findVIEwByID(R.ID.outdoor_activitIEs); imageVIEw.bringToFront(); imageVIEw.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent myIntent = new Intent(MainActivity.this, outdoorActivitIEs.class); startActivity(myIntent);});
总结 以上是内存溢出为你收集整理的java-images Intent不会随机打开.如果我按图像按顺序进行 *** 作全部内容,希望文章能够帮你解决java-images Intent不会随机打开.如果我按图像按顺序进行 *** 作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)