Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>It's definitely a Gallery!</strong></p> <p>You can see here that for sure it's a Gallery that comes with the SDK -> <a href="http://www.youtube.com/watch?v=hHh-lOnKuO4&amp;feature=related" rel="noreferrer">See Youtube video</a> to check how smooth it runs ;)</p> <p>I've made to myself a short guide from Android.com for future reference. I hope that you can use it too:</p> <p><strong>1) Open the res/layout/main.xml file and insert the following:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; </code></pre> <p><strong>2) Code to insert on your <code>onCreate()</code> method:</strong></p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Gallery gallery = (Gallery) findViewById(R.id.gallery); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(HelloGallery.this, "" + position, Toast.LENGTH_SHORT).show(); } }); } </code></pre> <p><strong>3) Create a new XML file in the res/values/ directory named attrs.xml. Insert the following:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;declare-styleable name="HelloGallery"&gt; &lt;attr name="android:galleryItemBackground" /&gt; &lt;/declare-styleable&gt; &lt;/resources&gt; </code></pre> <p><strong>4) Go back to your .java file and after the <code>onCreate(Bundle)</code> method, define the custom <code>ImageAdapter</code> class:</strong></p> <pre><code>public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Integer[] mImageIds = { R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; public ImageAdapter(Context c) { mContext = c; TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGallery); mGalleryItemBackground = attr.getResourceId( R.styleable.HelloGallery_android_galleryItemBackground, 0); attr.recycle(); } public int getCount() { return mImageIds.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds[position]); imageView.setLayoutParams(new Gallery.LayoutParams(150, 100)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setBackgroundResource(mGalleryItemBackground); return imageView; } } </code></pre> <p>Well... the code is very simple, but you can refer to the <strong>original and longer document</strong> <a href="http://developer.android.com/resources/tutorials/views/hello-gallery.html" rel="noreferrer">here</a>.</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.
    3. 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