Can someone point me to an Android example with source that allows the user to scroll through the contents of an xml file that contains text entries (preferrably with arrows on the side of the screen that allow previous/next type of interaction)
I've looked through the examples on the Android site and didn't see anything similar. Any help would be GREATLY appreciated (I'm an Android newbie but experienced Java developer)
I seriously doubt you are going to find a nice Android walkthrough of exactly the problem you are trying to solve, so you'll probably need to extrapolate from a few different guides.
Parsing xml is not substantially different from parsing xml anywhere else. This guide talks through the 3 different ways of doing so. Depending on how large your xml is, you can decide which makes the most sense for you.
In terms of UI, not sure exactly what you are looking for, but a ListView is often a good way to display large chunks of data. See Hello ListView.
Or, if you want a single text area that scrolls with 2 buttons, see ScrollView api. Its pretty simple. Common Layout Objects is a good guide to basic layout. You could probably accomplish what you want with a few nested LinearLayouts, or a RelativeLayout. If you post an attempt, people can help you fix it up.
Related
I am a junior developer and I am somewhat puzzled about writing xml layout files.
There are many implementations for the UI layout of the same style, RelativeLayout, LinearLayout, RelativeLayout And Linearlayout, and so on. Different implementations have different nesting levels. We know that there are as few nesting levels as possible, and that LinearLayout is used instead of RelativeLayout for the same number of layers.
But careful analysis, how do we measure the A implementation of a layout is better than B, two layers of nested LinearLayout really do not have a RelativeLayout to save performance? How to determine this? By experience? But where does the experience come from? It may be a good way to read the source code, but it is more difficult.
I think it is possible to find a good way of writing by analyzing the rendering time of an xml layout file and comparing the time spent on different implementations.
So I would like to ask everyone, is this a feasible way?
I'm not sure about, how we check the rendering time. But check below URL's one after one it may help you to understand more about rendering and performance related.
1) https://medium.com/#elifbon/android-application-performance-step-1-rendering-ba820653ad3
2) http://adavis.info/2015/03/android-overdraw-what-is-it-and-why-should-you-care.html
If i find any way to check the rendering time surely will let you know.
I'm creating an app that needs to display a table, with say, 30 columns and 30 rows. I want the user to be able to use swiping to move around the table/spreadsheet. The idea is that probably the entire table will not be visible on the screen, and if it is, it will hardly be readable, so there will have to be some max-columns-on-screen value. Each cell in the table must be capable of being a different color than the rest.
So far, I've looked into TableLayout. This doesn't seem to support different colors or swiping... actually, it does support different colors via .xml, but this isn't changeable at run time, and seems like it would be very messy anyway.
WebView looks to be an option, as I am proficient with HTML/CSS but can't find many resources about creating HTML and CSS content on the fly with android - only loading it; although I can imagine writing a file with the data and then loading it, and deleting the file. Not sure if any of this is good performance wise.
What direction should I head, before I start heading in the wrong direction? :-)
Yes, it is possible (and not difficult) to support different colors and gesture in the tablelayout rows.
I think it is always a wiser choice implementing the native components, once it has a better performance and it has a better layout adjust to different android versions.
Either method can solve the problem, so it's a judgment call based on your goals and requirements.
On the plus side for Android native views:
They are pre-compiled and easier to parse than HTML, so they will load faster, scroll more quickly, and require less memory.
If you intend to write a lot of Android apps you will need to learn them.
If you took this route, a typical approach to draw multiple columns would be a ViewPager with sliding tabs. See for example the Google Play Store app.
It's not the case that coloring native views dynamically is impossible or messy; it's not hard at all but it takes time to learn how, which brings me to the plus side for HTML/webview:
A programmer with expertise in HTML will solve problems faster by just using HTML.
Layouts designed in HTML for an Android web view can be re-used on other platforms.
Again, it's not really hard to load dynamic HTML into a web view. There are a few tricks you will need to learn but that's it.
I did search the internet to find an answer to my questions but there are no websites that did help me, so I hope someone can! Thank you in advance and have a nice day :-)
So these days I've been busy to get more into the Android Design guidelines and to learn more about it and how to implement it in my future applications. This is the main website I use to see what the guidelines are: http://developer.android.com/design/index.html. Great website but there are a few small things I just can't find in the dev guide or somewhere else. I just don't know how to implement some (simple) UI elements.
Can someone provide me code snippets of the following questions? (I want to know how to do it as simple as possible, how Google ment it!) It can help other (starting) developers too!
My main question is, are there special elements to achieve these things? As they are the key element in Android 4.0 it should have this things as some standard right?
1) Android 4.0 is using titles with dividers a lot in there new theme and it's looking great. But I can't find how to do implement this element simple like it should. What I want to know is how to make this blue title text with the grey looking divider underneath it look at this picture:
2) How to make section dividers in general? Like this image:
3) How to make a list with section dividers and give a list-item a 2-line explanation under it's name like this:
I did search the internet to find an answer to my questions but there are no websites that did help me, so I hope someone can! Thank you in advance and have a nice day :-)
In most cases how you are going to have to do it is create a custom layout. I tried recreating the look of the people application this way. for the most part the look you are going for is similar to the PreferenceActivityview. That gives you the look of the last image and probably how it was done in the People application with some extra programming. I just found it easier to create my own layout though instead of trying to mess around with that.
To my knowledge there is nothing in the api to create what you are looking to do easily and custom layout are going to be the way to go.
the custom dialog layout like you show in the beginning is very simple to do so if you dont know how to do manipulate layouts I would start there. look up the android color swatches to get the color of that blue
Edit
another thing you could do is look through the People source code and see how they did it but it will probably be more of a pain than what its worth when you can just do a layout
I'm working on an app that involves displaying comments from a website. These comments are threaded on the original site, so I'd like to replicate that experience within the app. I know that Android has an ExpandableListView, but it only does two levels and I was hoping for more.
Each top-level content would be aligned to the left. Replies would be indented by x units, replies to the reply would be indented x*2 units, etc.
Additionally, I'd like the ability for the user (or even the application code) to minimize/maximize threads. This would be particularly useful if the first comment has 8724 replies - you could just minimize the original comment instead of scrolling endlessly until you reach the second top-level comment.
What is the best way to present this multi-level list to the user? Are there any native/third-party classes/libraries I can use, or would I be better of coding this list in HTML and displaying that to the user instead?
I don't really think you should use a tree for displaying thread. Device screens are too small for this kind of widget. I would prefer multiple activities for displaying different levels of the thread. But I'm not a UI designer so my opinion may be far from the ideal solution.
EDIT: Here's an open-source tree-view widget: http://code.google.com/p/tree-view-list-android/.
I'm trying to create a memory game. I've looked at the Android tutorials for GridView and, while it works, it is somewhat difficult to understand and customize. I would like to ask for advice and opinions on what layouts I should use for the memory game I'm working on. It'll be a simple "grid" of pictures and people will be trying to find the matching pairs.
Please provide what you think would be a good layout to use and the advantages/disadvantages of that layout. Layouts such as Gridview, LinearLayout, TableLayout, etc.
Are there any layouts that are simple and easy to customize for my memory game? I'm asking as someone who is new to programming. I have watched an introductory programming video lecture series from Stanford using Java, so I understand the basics of Java but I am not advanced.
More information, just in case you want to know:
I initially tried to create the GridView in java and not XML. But for some reason, the GridView wouldn't display on the emulator. It was just a blank screen. I believe it was because I did not have the layout set to MATCH_PARENT. But I don't know how to do that from java. I tried googling it, but I couldn't find an answer. I eventually settled on doing it through XML. If anyone knows how to do it through java, that would be very much appreciated.
I also had difficulty understanding the ImageAdapter class in the GridView tutorial: (http://developer.android.com/resources/tutorials/views/hello-gridview.html). Specifically, I do not understand how or when the getView() function is called. It isn't explained in the tutorial.
I was able to get it to work but because I don't understand it very well, I am not sure how much I will be able to customize it for my memory game.
I'm sorry for the long post. My question is mainly about which layout I should use for my memory game. If you can answer the question about creating a GridView in java that displays on the emulator, that would be great.
Thank you for your time.
I wrote a fairly straight-forward tutorial for extending BaseAdapter - which is exactly what you'll want to do.
Define your layout in XML. Use a GridView. Then just write a custom adapter to control what gets displayed in the grid.
http://androidcookbook.com/Recipe.seam?recipeId=588
It's written with a ListView in mind but the same methods will be implemented for a GridView. If that is too advanced you'll need to start with a smaller app and build your understanding from a lower level.