JavaFX ListView with touch events for scrolling up and down

This is what I’ve made public class CustomListCell extends ListCell<Document>{ private double lastYposition = 0; public CustomListCell(){ setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { lastYposition = event.getSceneY(); } }); setOnMouseDragged(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { double newYposition = event.getSceneY(); double diff = newYposition – lastYposition; lastYposition = newYposition; CustomScrollEvent cse … Read more

How to change ListView height dynamically in Android?

This piece of code helped me to achieve dynamic listview height. import android.view.View; import android.view.ViewGroup; import android.view.View.MeasureSpec; import android.widget.ListAdapter; import android.widget.ListView; public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); for (int … Read more

System services not available to Activities before onCreate?

I would bet that you are trying to create a CursorAdapter in the Constructor of your Activity. Context is not available in the Activities Constructor, it is only available in the Activity.onCreate() method and beyond. And for a top tip… Create the CursorAdapter with a Cursor of null in Activity.onCreate() and use ListView.getAdapter().changeCursor(newCursor) to assign … Read more

Creating categories in a ListView?

How do I create categories in an arbitrary ListView like those in Preferences (PreferenceCategory)? I’ve found android.R.layout.preference_category that renders that grey TextView but don’t see it mentioned anywhere from java code. http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/ Note that the code is from Android 0.9 and may require minor modifications to work in Android 1.5. I have an Android 1.5-compatible … Read more

Windows 8 ListView with horizontal item flow

You can use a ListView this way: <ListView Height=”500″ VerticalAlignment=”Center” ScrollViewer.HorizontalScrollBarVisibility=”Auto” ScrollViewer.VerticalScrollBarVisibility=”Disabled” ScrollViewer.HorizontalScrollMode=”Enabled” ScrollViewer.VerticalScrollMode=”Disabled” ScrollViewer.ZoomMode=”Disabled” SelectionMode=”None”> <ListView.ItemsPanel> <ItemsPanelTemplate> <ItemsStackPanel Orientation=”Horizontal” /> </ItemsPanelTemplate> </ListView.ItemsPanel> — that gives it a horizontal panel and the right ScrollBars for horizontal scrolling. Both ListView and GridView can cause problems when you get larger items. I think by default the items … Read more