Android - switching between listviews without changing the layout? - java

I'm not looking for exact code here, just a direction on what to look for and what I should be reading about so I can figure this out.
I have a layout that I would like to remain static, with only the listview changing depending on what's selected from the list. I've reloaded data in the list, but I would like the fancy transition animations between choices, and would like the app to go to the previous menu when pressing back.
Someone suggested using a viewswitcher, which seems like it'd be great, but I am still unsure about how to fill a listview in a layout with a regular row layout, then on selection do an animated transition to a custom row. Also, it seems the viewswitcher is limited to two views, so it may be a limitation when I want to go a few menus deeper.
Preferably, I'd like to put each menu in it's own class so that I can handle filling it in that class, if possible...
Hope this isn't too vague, but if it is I'll be more than happy to explain myself further.

Don't know if it's what you meant but have you tried showing and hiding the views?
findViewById(R.id.listViewID).setVisibility(LinearLayout.GONE); //hide the one you want
findViewById(R.id.listViewID2).setVisibility(LinearLayout.VISIBLE); //show the one you want
Hope it's what you meant :)

Related

Floating Scrolling fragments in android through Java?

I would like to implement the following behavior in an android application:
So should I use fragments with horizontal ScrollView, a ViewPager or what exactly? Would it be better to use CardView?
And how to add the 2 dots at the bottom to show that we still have for example another page to show?
Finally, I need only one fragment/CardView to be present at a time. That is, I don't want to see half of the first fragment and half the second. That would be annoying.
I would like to know in general what pieces to use for this purpose.
Any help is much appreciated!!
I would use ViewPager. It will give you all of the functionality you're looking for and will allow you to add or remove pages easily in the future.
You will have to manually create a page indicator (the dots at the bottom) or use a library like this:
https://github.com/romandanylyk/PageIndicatorView

Is there a layout in android studio that is able to infinitely expand in every direction?

I'm relatively new to coding, especially with android(xml,java).
I had an idea for an app but it appears that it requires a layout that I can't seem to find.
So what I'd need is a layout that starts out with the screen size and dynamically expands in the given direction as the user drags along the screen.
In addition to that I want to be able to create objects(textview, imageview) at any given point on the layout which can also overlap as they can in Absolute- or RelativeLayout. Those objects should dynamically be loaded and destroyed as they move in and out of view.
So I don't know if there's anything like this. I've searched for quite a bit but only found layouts that were able to either scroll horizontally or vertically.
If anybody got an idea how I could possibly realize such a view, please let me know!
Best regards, BlackCert
In your case, doing everything manually through OpenGL seems appropriate. You could render only the items that are visible and dont have to mess with Android getting painfully slow when dealing with huge layouts. Set-Up a 2D scene and write rendering code for each kind of item you want to display.

Android: "Texting" List View?

I need some help.
I'm wanting to make an activity similar to this, but I'm not sure where to start.
Basically, it's like a texting UI, with the users question on the right and the answer on the left. I was going to use a list view for the sake of simplicity, but I dont' think it'd support this kind of structure.
I googled some layouts where I can scroll, but most of them require me to premake them, which isnt an option because its a dynamic chat log.
Does anyone here have experience with this kind of UI? Can you point me in any direction? I hate to ask such a strange question, but I don't even know how I'd word this situation on Google.
Thanks in advance.
What you're looking for is a ListView where you can return a different layout depending on whether the message is sent or received. A ListView is the most efficient implementation for this because its ideal for displaying a potentially large data set without having to keep a view in memory for every row.
This is achieved by extending the BaseAdapter in your application and overriding the getItemViewType(), getViewTypeCount(), and getView() methods (along with all the other methods required by a ListView adapter).
This is a good tutorial that serves as a walkthrough for this pattern.
Instead of using ListView, You may programmatically construct a viertical LinearLayout, and add TextView in each line, you can set the alignment of the TextView in lines accordingly.

What in Android would allow me to touch the edge of my screen while playing my game and slide over an Item screen?

Android has many useful tools when coming to views and screens and layouts.
Description: While playing my game (running around as a zombie bear eating humans) I would like to allow the player to access an items menu via sliding a menu from the right side/edge of the screen. Or at the least be able to access a game options menu (not game settings which would be the menu button).
What would be the best fit for description?
P.S How would I make a question like this less like a discussion and more like a straight forward programming question when I don't really know what's available to do this.
Also, if this is the case, please point me to another location to ask a question that may require a discussion.
Thank You!
Try looking at the SlidingDrawer class.
PS I personally don't see a problem with how you have worded your question if you are looking for ideas of views/widgets you need to perform a specific function/effect.
My first thought, and for a simple approach (this wouldn't be animated or dragged really), would be using a RelativeLayout where the portion representing the menu was initially set so that it's visibility were GONE, except for a small tab or arrow or something. When that tab/arrow is touched, the visibility of the View for the menu could be toggled to VISIBLE.
With visibility set to GONE, a view is not drawn or considered in any part of the layout pass when the screen is drawn.
You could populate a listview with some icons and when an particular icon is selected, then figure out which one was selected and then execute some function and hide the sidebar using an animation. I've never developed a game, so I'm not too sure how far it deviates from the standard, but I wish you the best of luck :) ! If you post the source let me know would love to test your game and see how you work with the source!

Android: Creating a Scrollable Layout

I'm trying to create a "scrollable" layout in Android. Even using developers.android.com, though, I feel a little bit lost at the moment. I'm somewhat new to Java, but not so much that I feel I should be having these issues--being new to Android is the bigger problem right now.
The layout I'm trying to create should scroll in a sort of a "grid". I THINK what I'm looking for is the Gallery view, but I'm really lost as to how to implement it at the moment. I want it to "snap" to center the frame, like in the actual Gallery application.
Essentially, if I had a photo gallery of 9 pictures, the idea is to scroll between them up/down AND side to side, in a 3x3 manner. Doesn't need to dynamically adjust, or anything like that, I just want a grid I can scroll through.
I'm also not asking for anyone to give me explicit code for it--I'm trying to learn, more than anything. But pointing me in the right direction for helpful layout programming resources would be greatly appreciated, and confirming if it's a Gallery view I'm looking for would also be really helpful.
EDIT: To clarify, the goal is to have ONE item on screen at a time. If you scroll between one item and the next, the previous one leaves the screen, and the new one snaps into place. So if it were a photo gallery, each spot on the grid would take up the entire screen size, approximately, and would be flung out of the viewable area when you slide across to the next photo, in either direction. (Photos are just an example for illustration purposes)
This page gives a good summary of the different built in layout objects. From your description a GridView or possibly a TableLayout might work. GalleryView looks to be horizontal only.
I believe GridView is what you're looking for. Here's a tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html
You should check out the ViewPager widget, which is available in the Android compatibility package. I spent a loooong time trying to get the Gallery widget to behave properly, but finally settled on a ViewPager which returned ImageView objects instead. Works like a charm.

Categories

Resources