Note that there are some explanatory texts on larger screens.

plurals
  1. POChange view onClick coverflow - Android
    primarykey
    data
    text
    <p>I'm using this CoverFlow : <a href="http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html" rel="nofollow">http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html</a></p> <p>I want to be able to change View when I click on a button, the button being a back/forward icon which will take you to the previous/next item in the coverflow.</p> <p>I have modded the coverflow slightly so that I use an XML layout instead.</p> <p>Here is my onCreate() method:</p> <pre><code> setContentView(R.layout.main); CoverFlow coverFlow = (CoverFlow)findViewById(R.id.coverflow); coverFlow.setAdapter(new ImageAdapter(this)); ImageAdapter coverImageAdapter = new ImageAdapter(this); coverFlow.setAdapter(coverImageAdapter); coverFlow.setSpacing(-20); coverFlow.setSelection(0, true); coverFlow.setAnimationDuration(1000); tv = (TextView)findViewById(R.id.textView1); coverFlow.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { Toast.makeText(getBaseContext(), String.valueOf(arg2), Toast.LENGTH_SHORT).show(); } }); coverFlow.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { tv.setText(String.valueOf(arg2)); } @Override public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // Do something } }); </code></pre> <p>My XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/home_background" android:orientation="vertical" &gt; &lt;com.demo.app.coverflow.CoverFlow android:id="@+id/coverflow" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="39dp" android:layout_marginLeft="35dp" android:background="@drawable/button_left" /&gt; &lt;Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="39dp" android:layout_marginRight="35dp" android:background="@drawable/button_right" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="55dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="hello" android:textColor="@color/White" android:textSize="16dp" /&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_marginRight="170dp" android:layout_marginTop="15dp" android:src="@drawable/unsa_logo" /&gt; &lt;ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="14dp" android:layout_marginTop="23dp" android:src="@drawable/pnc_logo" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    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.
 

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