Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're not starting new Activities, you're merely switching layouts in the first Activity. So the first button will work because it has a listener assigned to it in MainActivity. However <code>b3</code> is is another Activity which never gets started, so depending on what you want to do, you can either start a new Activity for each button click, or you can move <code>b3</code>'s Listener inside <code>MainActivity</code>.</p> <p>First method (new Activities)</p> <pre><code>ImageButton b1 = (ImageButton) findViewById(R.id.button_compare); ImageButton b2 = (ImageButton) findViewById(R.id.button_find); b1.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View comparePage, MotionEvent event) { startIntent (new Intent (MainPageActivity.this, Compare.class)); return true; } }); b2.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View findPage, MotionEvent event) { startIntent (new Intent (MainPageActivity.this, Find.class));//You will NEED to make a new Activity called Find. return true; } }); </code></pre> <p>The second way (resetting content views in the same activity). I do not recommend it, since it makes things messy and goes against what an Activity should be, but it's still a (bad) option.</p> <pre><code>ImageButton b1 = (ImageButton) findViewById(R.id.button_compare); ImageButton b2 = (ImageButton) findViewById(R.id.button_find); b1.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View comparePage, MotionEvent event) { setContentView(R.layout.compare_pagee); ImageButton b3 = (ImageButton) findViewById(R.id.compareButton); b3.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View comparePage, MotionEvent event) { setContentView(R.layout.compare_pagee); return true; } }); return true; } }); b2.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View findPage, MotionEvent event) { setContentView(R.layout.find_page); return true; } }); } </code></pre> <p>As you can see, b3's Listener extremely redundant - it doesn't do anything useful. </p> <p>I suggest rethinking what you want your code to do, and rewriting it properly, since this is not proper structure.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload