No section wrapping in UICollectionView - layout

I am using UICollectionView to display cells but I would like to change the default wrapping behaviour in the sections. I don't want any wrapping, instead, I would like the equivalent of a variable width horizontal scrollview for each section, like shown in the following image.
I can do this using horizontal scrollviews within a vertical scrollview but I would like to use a collection view. Any idea on how to do this with a custom flow layout maybe?
Thanks!

You can nest collection views, but you have to be careful separating their delegates to avoid having one collection view being affected by a call to the other.
Create the first collection view with vertical scrolling and as many sections you like. Its delegate must be the controller view it is embedded in. Subclass its cell.
Inside the first collection view's cell create a second collection view with horizontal scrolling. Its delegate is the cell of the first collection view.
You can find an example here: Issue with nested UICollectionViews

Related

Creating a custom layout for horizontal buttons with wrapping

I wasn't sure what to title this without explaining it all there. Essentially, I want to populate part of a screen with a bunch of buttons. The buttons should have text from an ArrayList (or other structure) and they should be aligned horizontally to each other from the left to the right of the screen. When there is no more room to the right, it starts a new row. I've attached an example. Example layout here
I know how to make custom list adapters for my objects and how to make listeners for parts within the list items, but I'm just not sure how to make the "list" of buttons go horizontally with wrapping to the next line.
It seems https://github.com/google/flexbox-layout might help you.
You can use FlexboxLayoutManager as adapter, or simply place all the buttons inside FlexboxLayout, they will wrap automatically depending on their width.

Is there a way to create a widget with configuration wrap and select_range method?

I have a problem. In Tkinter there are two widgets: Text and Entry. The Text widget has a configuration wrap='word'. And the Entry widget has a method select_range. I need both the wrap configuration and the select_range method in order to select certain parts of a massive text (by select I mean like with the mouse).
There is no direct way to combine the features of two different widgets, but there's really no need to do that. All you're asking for is the ability to select a range of text, and the text widget supports that.
The method to select a range of characters is documented. All you need to do is add the tag "sel" to a range of characters.

Linearlayout like a "ListView" containing objects in android?

I am making a list using LinearLayout and would like to add several "person"-objects to my "list"
I need to be able to click on an object in this list an pull out the person object or at least the personId to be able to find the specific person in my database.
How do I go about doing this?
I have tried using a TextView but it is too simple to contain all of the desired values.
I have also tried using a ListView but I have several LinearLayout next to each other. The ListView scroll individually and therefore I can't use them
Here is an image:
As you can see I am trying to make a grid of sorts each column is a linearview and at the moment so are each row.
I realize there is a grid but I need to be able to fit objects in where I want them and I am too inexperienced to write my own adapter for the gridview
You can achieve this using a ListView with a custom ArrayAdapter.
Check out this example.
Instead of the Weather class, use your own Person object and make the necessary modifications.
Edit:
After reading your edit, I can see that you have some kind of Grid. So my best guess would be to use a GridView with a custom adapter.
Since you are getting your data from a database, you might as well use a custom CursorAdapter.
But I still haven't figured out what you're trying to do.
It seems that you want all the cells to be visible. That would only mean you have a small/finite amount of cells, and in that case a GridView wouldn't be any better than a for loop that adds views to a layout.

How do I create a pager for a view that shows the alphabet instead of numbers?

I have a need to have an alphabetical pager for a view. I didn't see any of the samples or the custom pager that addresses this. I would think that this would be a pretty common thing.
MJ
I'm not quite sure what you really mean by an "alphabetical pager", but I assume you might be looking for some kind of alphabetical navigator like we have it in the personal NAB inside the Notes client, right?
If so you're not really looking for a pager but for an alphabetical view filter. Here's one way to get there:
create a panel, give it a distinctive ID like "viewContainer" or
something. Put your view panel into the panel; of course the view's main sorting order must be alphabetical
create a 2nd panel above "viewContainer", no ID necessary here
put a repeat inside this new panel and bind it to a new JavaScript array, like that:
new Array("a", "b", "c", ... , "x", "y", "z");
enter a collection name for the repeat, like "letter"
put a link control inside the repeat. The link's label will be
computed to the repeat's collection name, i.e. "letter".
assign an onclick event to the link setting a sessionScope variable to the current collection name's value, like that:
sessionScope.filter = letter;
set the event's refresh mode to partial so that it refreshes your viewContainer panel
highlight your view control inside the viewContainer. In its data properties look for the property field labelled "Filter by column value" and make it computed. Enter this code:
sessionScope.filter;
That's it.
Edit:
of course you can build the repeat's datasource array dynamically from the view itself. So, instead of building that static a-to-z array you could also use something like this:
#Unique(#Left(#DbColumn(#DbName(), "yourLookupView", viewColNumber), 1));
That should return an array only containing those letters that really are in your view.
Also you could another static link control outside the repeat resetting the filter to show all entries. It would be built like the repeated link with the onclick event calling this code:
sessionScope.filter=null;
Enjoy!
I would go for this: make a view categorized by formula #Left( value; 1). Then render result of #DbColumn as pager by repeat or some ExtLib component (links list, navigator, menu). Each link will either limit shown view to "single category" or jumps to "starts with" character.

DrawItem in listbox (VC++)

When we will use DrawItem for a listbox?
Normally, if the listbox is ownerdraw, we will use DrawItem. What are the other senarios we use drawitem?
To elaborate on Rashmi Pandit; A ListBox with override DrawItem can also be used to 'visualize' objects. In a project I'm working on, a ListBox is used to display rows from a database. Each row / item is visualized using formatted Strings, Icons etc.
Overriding DrawItem (and MeasureItem!) is ideal for this purpose. Of course, the internal structure has to be tweaked a bit (the standard Items property cannot be used for objects), but it is certainly worthwhile.
Message WM_DRAWITEM is sent only to owner-drawn List boxes.
You can use DrawItem when you want to override the default implementation and custom the way a listbox is drawn. For e.g. in the list there might be some item which should is the default item and you would want it to be highlighted so that the user knows it is the default item.
Here's an eg for a combo in C#: Higlighting a particular item in a combo box

Resources