Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to be able to enable/disable scrolling of the Gallery, you could use class like this:</p> <pre><code>public class ExtendedGallery extends Gallery { private boolean stuck = false; public ExtendedGallery(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public ExtendedGallery(Context context, AttributeSet attrs) { super(context, attrs); } public ExtendedGallery(Context context) { super(context); } @Override public boolean onTouchEvent(MotionEvent event) { return stuck || super.onTouchEvent(event); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: return stuck || super.onKeyDown(keyCode, event); } return super.onKeyDown(keyCode, event); } public void setScrollingEnabled(boolean enabled) { stuck = !enabled; } } </code></pre> <p>According to the Gallery source code, there are two event types that start the scrolling: screen touch and the key, pressed on D-pad. So you could intercept these events if you want to disable scrolling. Then use something like this in your layout:</p> <pre><code>&lt;your.package.name.ExtendedGallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>Then you can enable/disable scrolling of that gallery at any time:</p> <pre><code>ExtendedGallery mGallery = (ExtendedGallery) findViewById(R.id.gallery); mGallery.setScrollingEnabled(false); // disable scrolling </code></pre>
    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.
    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