Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use viewswitcher with same id's in both layouts
    primarykey
    data
    text
    <p>I am using view switcher in my project.</p> <p>In my xml I have created 2 layouts with all same Id's. After I switch my view I can not switch to previous view because I am using same ID's in both layouts.</p> <p>Now how can I use one listener in java code for both layouts in view switcher. I dont want to create an another id and create another listener to switch again.</p> <p>My xml is as below.</p> <pre><code>&lt;ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/profileSwitcher" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="@string/hello_world" /&gt; &lt;Button android:id="@+id/switchBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:text="Switch" /&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:text="@string/hello_world" /&gt; &lt;Button android:id="@+id/switchBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="Switch" /&gt; &lt;/RelativeLayout&gt; &lt;/ViewSwitcher&gt; </code></pre> <p>My java code is as follows</p> <pre><code>final ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.profileSwitcher); Button btn = (Button) findViewById(R.id.switchBtn); btn.setOnClickListener(new OnClickListener() { private boolean switchCheck; public void onClick(View v) { new AnimationUtils(); switcher.setAnimation(AnimationUtils.makeInAnimation(getApplicationContext(), true)); if (!switchCheck) { switcher.showNext(); switchCheck = true; } else { switcher.showPrevious(); switchCheck = false; } } }); </code></pre> <p>Please help..</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. 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