Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I would recommend doing is extending ListView in your own custom class. Define a class called MyListView, or something similar, and make sure you define all three constructors. Then, override the onSizeChanged method to call something externally - much like an OnClickListener or OnTouchListener. You could define a method in MyListView to accept a listener, instantiate a listener in your activity, and then when onSizeChanged is called, pass it on through to the listener. This is really hard to explain in English. Here is some sample code:</p> <p>Custom ListView:</p> <pre><code>public class MyListView extends ListView { public MyListView(Context context) { super(context); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); } public MyListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public void SetOnResizeListener(MyOnResizeListener orlExt) { orl = orlExt; } @Override protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld) { super.onSizeChanged(xNew, yNew, xOld, yOld); if(orl != null) { orl.OnResize(this.getId(), xNew, yNew, xOld, yOld); } } MyOnResizeListener orl = null; } </code></pre> <p>Custom listener:</p> <pre><code>public class MyOnResizeListener { public MyOnResizeListener(){} public void OnResize(int id, int xNew, int yNew, int xOld, int yOld){} } </code></pre> <p>You instantiate the listener like:</p> <pre><code>Class MyActivity extends Activity { /***Stuff***/ MyOnResizeListener orlResized = new MyOnResizeListener() { @Override public void OnResize(int id, int xNew, int yNew, int xOld, int yOld) { /***Handle resize event****/ } }; } </code></pre> <p>And don't forget to pass your listener to your custom view:</p> <pre><code> /***Probably in your activity's onCreate***/ ((MyListView)findViewById(R.id.MyList)).SetOnResizeListener(orlResized); </code></pre> <p>Finally, you can add your custom list to an XML layout by doing something like:</p> <pre><code> &lt;com.myapplication.whatever.MyListView&gt; &lt;!-- Attributes --&gt; &lt;com.myapplication.whatever.MyListView/&gt; </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