ListView Card layout Scrollbar and spacing issues - java

I have attached a screenshot of my app with some junk data. The white that takes up the entire ListView is supposed to only be for each item, creating a card layout. I am new to Android, and cannot figure out where my code makes the incorrect reference.
The layout for the individual card is here: http://pastebin.com/mxjiDTLF
The layout for the activity is here: http://pastebin.com/kstW9PqV
The EventAdapter.java class that displays the Event objects in the listview is here: http://pastebin.com/vXkBnPq0
Also, in the below screenshot, you can see that the scrollbar does not appear right next to the left edge of the screen, but just inside the "white" of the massive card. What do I need to do so that it does not appear there?

Most layout parameters are ignored for ListViewItems. You should wrap the contents in the list view item inside another layout that has the correct margins, something like here (not tested): http://pastebin.com/bW7s27in
The fact that your scrollbar is not at the edge of the screen is caused by the margins of the ListView in your activity_events.xml file. You should set those to 0.

You should set the card background to each item.

Related

Android studio: How to dynamically display and refresh a custom list which is horizontally and vertically oriented at the same time?

So I've been developping an app on Android Studio and at some point I need to display couples of values composed of texts and images but I have some issues with the display.
Let's say here that I want a list of fruit names associated with a picture, I'd like to display it that way :
Example
Each image and its related text is in linearlayout, so it's a list of linearlayouts.
The "add fruit" button open an alerdialog where the text and the image can be chosen, by clicking the 'ok' button in the alertdialog the name and the image are saved in a sqlLite database (which I already have programmed), and the linearlayout has to be added in the current list as the dialog is dismissed.
So the issue here is that:
I don't really know how to dynamically display each one of these linearlayouts in this specific order.
I don't know how to make it so that when a new fruit is added and the dialog dismissed, the list in the activity is refreshed directly.
I've been thinking of using a listview but listviews are only horizontal OR vertical but in this case I kind of need a mix of both.
Another idea was to delete the layout containing all the linearlayouts (all the list) when a new fruit was added, and then take my database to create all the linearlayouts again. But dynamically I don't think it will work, the refresh won't be done (?)
My last idea was to create a fragment and use my database in the onCreateView method to display every elements. And to refresh it, I'll just detach and attach again the fragment to the activity each time I add a new element.
I don't think my ideas are the optimal or even a correct way to do it, I've been struggling with it for a while. If you have any suggestions or ideas to help me, it would be great :)

How to change items' properties in RecyclerView when chosing a specified item programatically?

I want to change the background colour of an item in a list in RecyclerView using LinearLayoutManager.scrollToPosition(mPosition). I have two buttons which increment or decrement the position number. So, on specifying an item (going to that position using scrollToPosition), I want to highlight it (changing background colour for instance) to indicate the specified one. The case is that we don't have to use touch to scroll up and down and selecting the items (something like using tab key on keyboard to jump between items in the recyclerview).
I've tried OnFocusChanged and assigning an xml instead of background to see the different behaviors like on state_selected or state_focused but none of them was correct. So, What should I do?
If I understand correctly, you want to change the background color after scrolling to this position?
Try this:
LinearLayoutManager.scrollToPosition(mPosition)
View view = LinearLayoutManager.getItem(mPosition);
view.setBackgroundColor(color);

Android HorizontalScrollView Snap and Center Focus

Fairly new to Android dev. I am trying to create a HorizontalScrollView that snaps and filters images based on the centered object selected in a list. In the picture below, notice how the letter in the center of the screen should perform a set of specific commands. For example, when I scroll to "C" a popup with the message "C" should pop up.
I have created the HorizontalScrollView and populated the view with buttons. I am trying to figure out how to make it snap and how to identify the letter in the center at any given moment.
I have taken a look at ViewPager, but I don't think it will be able to do what I have described because I would like to have a set of letters displayed at any moment. I understand I will probably have to create a custom class. Could you provide any guidance?

JavaFX: iTunes-like, expandable and collapsable Panel

I would like to create something like this in JavaFX:
The Panel with the song titles is expanded and collapsed by clicking on the album cover. The other albums are moved down when it's expanded and up again when collapsed.
What would be the most simple way to do this? I thought of using an Accordion, using the images as titles, but I'm not sure if it can be stylized in a way that it looks like this.
Since the icons should be realigned when the window size is increased, I'd like to use a Flow- or Tile Pane for the main layout. Animation would be nice-to-have, but is not absolutely necessary.
I'm grateful for any hint!
I cannot think of a simple way to have the albums in the second row to move down. However, if you want a grid of albums and a pop-over that appears when the user clicks on the album, the ControlsFX library’s GridView and PopOver control may help you. Although the GridView example in the link above shows only images, you can embed a whole scene graph (the image icon of the album, the title label, and the artist name label) in each cell.

Strange glitch on ListView: text dissapears after pressing search action button

I've a ListView screen that is driving me mad.
Each row has three TextViews. The adapter is a custom ArrayAdapter that makes use of the view recycling mechanism: if the row is first requested, a new view is inflated, otherwise the recycled view is used. Everything works ok. I'm not showing it but for now assume it is correctly implemented.
This is how it looks normally:
There is a search button in the right upper corner of the screen. When clicked, every text view in the list is "cleared"! I've debugged the code and the textviews are there, the text is set and everything is ok except the text is barely or not shown. Here's a view dump taken with DDMS:
Looks like only the first letters of the text are shown. This only happens in certain devices, and only when the adapter's getView method returns the recycled view for the row, BUT only after pressing the search button, which makes the keyboard to show up (If i close it, the text is still missing). If I modify the getView method to always inflate every row this does not happen, but of course this is not an option since my list should be able to handle a large number of items.
Looks like a bug, but I need to do something about it.
I've also tested an alternative recycling mechanism based on a map (basically I put the view for each row in a map). Still the behavior is observed.
Device is a Samsung Galaxy SII running 4.1.2. Not happening in Galaxy SIII mini for instance.
Do you know what could be causing this glitch? Something related to the TextView's width?
Thanks in advance
I finally found the cause.
It was one of the TextViews in the adapter xml file. It was contained in a fixed-width LinearLayout. Its width was set to fill_parent, and changing it to wrap_content fixed the issue.

Categories

Resources