Note that there are some explanatory texts on larger screens.

plurals
  1. POSwipe / (Fling) with dynamic views
    text
    copied!<p><strong>What i want to:</strong></p> <p>I want to add a swipe or what i learned it's named on android fling, to my app. I have a dynamic number of views, the number is the amount of dates from an ICS file which i parse, i want to make a swipe effekt on all of these views together. But if i have let's say 12 of these each having a ListView with 8 items (max) it would use a lot of memory i guess. So i would like that only the 2 before current selected view and the 2 after to be initialized.</p> <p><strong>What i have tried:</strong></p> <p>In my search i stumpled around <a href="https://stackoverflow.com/questions/5071743/how-to-make-an-android-view-that-flips-between-views-on-swipe-fling">this stackoverflow question</a> which mentions HorizontalPager. But i dont know to make it work with a number of ListView's and load them dynamically.</p> <p>I tried a ViewGroup and then add and remove a ListView but it's not working, it display's the ViewGroup but not the ListView</p> <pre><code>public class HourView extends ViewGroup { private ListView listView; /** * @param context */ public HourView(Context context) { super(context); init(false); } /** * * @param context * @param day the current day */ public HourView(Context context, String day, boolean shouldBeVisible) { super(context); this.day = day; init(shouldBeVisible); } private void init(boolean shouldBeVisible) { if (shouldBeVisible) { listView = new ListView(getContext()); if (day == null) { day = Event.dtFormatDay.format(new Date()); } new GetEvents(day).execute(); addView(listView); } else { removeAllViews(); listView = null; } } } </code></pre> <p>The GetEvents() is a AsyncTask (a class inside the viewgroup class) that gets some events from a local database, the code is the onPostExecute is as follows</p> <pre><code>protected void onPostExecute(String errMsg) { if (errMsg != null) { listView.setAdapter(new SkemaHoursRowAdapter(getContext(), eventItems)); listView.requestLayout(); addView(listView, layoutParams); } } </code></pre> <p>eventItems is an array i parse to my custom rowadapter (which i know works). The view group is displayed but the listView is not. </p> <p>Any suggestions??</p>
 

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