XML for Android Programming - android

I just picked up the Android Apps for Absolute Beginners and I read the introduction, it turns out you have to know Java.... so I read Sam's Teach Yourself Java And 24 Hours and I thought I was ready to dive into Android programming. When I began reading the book I noticed there was a lot of XML stuff and I don't know XML.. my question is, how much XML do you have to know in order to write Android apps. Can someone recommend a book or resource that has information about XML and Android? I have about three years of Objective-C experience and a couple days of Java experience.
Thanks!

You don't need to know much about XML. Most of what you need can be absorbed by imitation. You don't need to know much more than the basics of XML syntax. (An easy XML tutorial can be found at W3Schools. An even briefer tutorial, as well as links to the W3Schools tutorial and other learning resources can be found at the XML Introduction page at the Mozilla Developer Network site.) As to concepts of how XML and Java work together in Android, I'd strongly recommend that you go through the training material on XML at the Android web site.

OK so there are a few questions in here that need breaking down...
"how much XML do you have to know in order to write Android apps"
You need to know the basics. XML is not a programming language (as I am sure you are aware) and is a markup language. If you have 3 years of C under your belt this will take you all of a day at most to get your head round if not less.
Read the W3 Schools guide to XML http://www.w3schools.com/xml/ it has everything you need.
"it turns out you have to know Java.... so I read Sam's Teach Yourself
Java And 24 Hours and I thought I was ready to dive into Android
programming"
Your existing knowledge should serve you well but spending 3 days on a language may simply not be enough (unless you are amazing in which case i retract this statement). Java in my own opinion is quite as nice language to learn and you should pick it up quite quickly with a little time.
Have you read the Android Developers documentation? Read it well, it has lots and lots of help. Every time I seem to write an answer or comment I reference the documentation. Have you checked the samples? I find learning by example/practically quite useful and far more engaging.

You should see and learn developer.android.com for android developers. In this website, you'll know about XML s very well and they're also sample to understand. You don't need to think about that. Check it out.

Please be aware that this answer is mostly focused on Android application development using Android Studio and may not be true for other development tools and methods.
XML is a markup language used for styling Android applications, it is generally used as a means of separating the application’s styling from the actual logic - meaning that that the “image” and “functionality” of the application are separate and if one changes, the other does not have to.
To develop an Android application, you don’t need to know XML, On Android's Developer website - it states that you can either style your application at runtime using Java or use XML. Though a basic understanding of XML may come in handy for problem-solving.
And even if you wish to use XML to style your app - you don't need /an in-depth knowledge of it as you can simply use Android Studio’s Layout-Editor (only versions 2.3 or higher can do this) - which will allow you to style your application visually and generate the corresponding XML afterwards which you're free to edit if you please.
Sources
https://developer.android.com/guide/topics/ui/declaring-layout.html
https://developer.android.com/training/basics/firstapp/building-ui.html#strings
Also see:
- TutorialsPoint's Android tutorial titled "Styles and Themes"
- W3Schools' XML tutorials.
- As well as any of the appealing links on Android's developer website, TutorialsPoint and off-course W3Schools websites.
Forgive me for any mistakes in this post and you're free to correct them, forgive me for my inability to provide all the relevant links (due to my low reputation) and I hope this helps at least someone.

Related

React-Native cross-platform example write once and use anywhere or DRY?

I am very new to React-Native and love it so far. Really great technology and very impressive tooling. I would like to propose it for use in my company.
However ... react-native examples demoing code-sharing btw Android and IOS platform are simply nowhere to find??? All I have found after 3-4 weeks looking into it is few excellent but only IOS examples. Below, are just few examples of articles lacking this. Although some of them claim in their title to cover both, they cover only IOS:
https://www.raywenderlich.com/165140/react-native-tutorial-building-ios-android-apps-javascript
https://mentormate.com/blog/react-native-components/
http://www.andevcon.com/news/take-a-crack-at-react-native-with-kyle-banks
https://appendto.com/2016/11/build-a-coffee-finder-app-with-react-native-and-the-yelp-api/
https://reactjs.co/react-native-convention/
https://www.lullabot.com/articles/build-native-ios-and-android-apps-with-react-native
https://code.facebook.com/posts/1189117404435352/react-native-for-android-how-we-built-the-first-cross-platform-react-native-app/
https://medium.com/#MentorMate/best-practices-for-building-an-app-with-react-native-components-7dee3b2b010f
https://code.tutsplus.com/tutorials/creating-a-dictionary-app-using-react-native-for-android--cms-24969
http://facebook.github.io/react-native/docs/tutorial.html
... , this list could continue on and on but it should be enough to demonstrate the lack of good resources I'm talking about.
I understand react-native is cross platform in terms that you can write code for both Android and IOS, that is all clear and great.
But is it sharing the code? In other words, is it DRY? From what I see, it is write once for each platform rather than write once for all platforms. Again, I understand some Views (but not all) are platform specific but again, there is no example to show even that on both Android and IOS in the same project.
Where is a non-hello-world (real life) example to clearly demonstrates and teaches how to do that? React native used to have it in version 0.20 or so but it was removed and replaced with a HelloWorld example? Seriously #Facebook???
As per links above, lots of React-Native articles out-there are titled to cover both platforms but then they only talk about IOS without even mentioning any other platform? Very few talk about Android only, again, not even touching other platform in the same project. ... and lots of them are outdated!
I understand that the technology is very new (and very good from what I have seen so far, I really love it).
But assuming I have to propose React-Native as a next-gen platform to a company, I do not see any convincing cross-platform, code-sharing examples demoing this for both Android, IOS (UWP??) that I could help me learn, understand, build, and demo an example for that proposal.
I am not looking for chatty comments or links to courses but rather examples to show how to do this in more than just CRNA generated HelloWorld app.
Found the answer here https://www.codementor.io/vijayst/build-react-native-retrofitting-ios-app-to-android-gsf5uyl1q in the very 1st paragraph and it is exactly what I have been trying to get RN/Facebook answer but they ignored the question all the time.
Very disappointing!
So, ReactNative is not "build-once-use-everywhere" but rather "learn-once-use-everywhere" meaning lots of code duplication. And by everywhere, they mostly mean Android and IOS although the examples out-there are mainly IOS. If they cover both platforms, then it is with almost no code sharing but lots of code-duplication.
Although, RN claims they can achieve up to 90% of code sharing, that is not demonstrated anywhere that I could find. Documentation is very shallow in touching anything let alone topic of code-sharing and the tutorial provided by RN is a HelloWorld, ... yes, seriously. Sad! Although they used to have a better tutorial in older version (like 0.20 or so).
In terms of recommending RN to a company as a next-gen platform, I see few issues
concerning patent license, no answers no explanations, very obscure and concerning for a company that would consider moving to this, I'd rather say open-source under quotation marks. Hopefully this will change as I see it as a mayor showstopper for anyone considering adapting this technology. I would say this is no more applicable as FB made react-native licensed using MIT as per https://github.com/facebook/react-native/issues/16079
documentation that is very basic without giving depth of explanation. For example, this is react-native site with demo sample to demonstrate code-sharing cross-platform nature (I warn you, it is a HelloWorld example) https://facebook.github.io/react-native/docs/tutorial.html
React Native Community facebook page which is the page where you are supposed to find help and ask question as per react-native site will simply block you if you bring this topic on and will not let you in
even here on SO, questions like this (after extremely thorough and time consuming research) will earn you only downgrades and zero answers or even attempts
examples lack clarity and depth of explanation, it seem like whole community follow one pattern, copy / paste demonstrating code-duplication rather than code-sharing
Most examples cover (to most basic extent) only IOS although most claim cross-platform nature on both Android and IOS with Android being mentioned in the title only and the body covering only IOS
Impossible to ask for help on react-native site
Impossible to suggest improvement on react-native site other than create pull request. In other words, they want you to work for them for free
The framework is cross-platform, that is great but it is more of a copy/paste (copy from IOS into Android, then modify what needs modification) rather than code-sharing strategy. Every example I was able to find and it took me a month, was a violation of DRY principle in its best form
Although I mentioned things that bothered me at most during my research, I have to say that I hope this technology will thrive and become clear open source platform in future. I really like it and hope someone at #Facebook / #ReactNative will consider these suggestions, or at least provide improvements in the documentation, examples, access to community, place to ask questions and get help, clear licensing, ... all of which I was not able to get after spending a month researching RN.
Perhaps the technology is still not mature enough, which makes sense, it is very new.
Would I recommend it?
To developers yes, definitely. I really like it myself and will spend more time studying it.
To a company? Not really for the reason explained above.
UPDATES - Getting Better :):
... and to add my 2c to anyone who faced the same problem and contribute to community (at least in terms of finding tutorials that talk about both IOS and Android), I will keep posting links I have managed to find so far:
https://differential.com/insights/sharing-code-between-android-and-ios-in-react-native/ is very basic example. Not really code sharing but rather code duplication but at least something
https://www.codementor.io/vijayst/build-react-native-retrofitting-ios-app-to-android-gsf5uyl1q, also more of a code copying rather than code sharing but hey... going somewhere
https://hackernoon.com/getting-started-with-react-navigation-the-navigation-solution-for-react-native-ea3f4bd786a4 another good one
This document explains that RN philosophy is "learn once, write anywhere" rather than "write once, run anywhere" http://makeitopen.com/tutorials/building-the-f8-app/design/

ScrolledListView in Android

I found this Image on the web and want to use a such list in android. Do you have an idea where I can find a such List in Android Studio?
There are certain lists that others have provided as free source code to be used within your applications. What you have discovered is not a built-in feature of Android (the IDE has not relevance on this).
You can however find resources to use a wheel such as those. One of which used in the past has been from the android-wheel code. Most will demonstrate examples and provide useful tips on going forward with implementation. But you can find others if you look hard enough.

How to manipulate Android classes

New to Android. Trying to find docs that show what Android classes expect to elicit changes. For example, to make a keyboard always visible, I could find some info searching Google, but not directly in the docs of the SDK. Is there a source for more comprehensive docs on how Android works not just from the individual class level, but how it boots up and what to do to make small tweaks for an app.
I don't know if this would be what you're looking for, but here's some information on packages and classes
http://developer.android.com/reference/android/inputmethodservice/package-summary.html
I've been teaching myself Android for about a month now and the best reference I've found so far is the Android Developer site, especially under the References and Resources pages.
Hopefully that helps a little bit. Sorry I couldn't be of more help.

Android App - XML or java

I am currently starting to create an app for a small charity company. But I'm not entirely sure how to properly learn how to code for the Android OS. I have searched online for tutorials, but most stop at the same stage and only show you how to launch the "helloWorld" app.
My question is this:
1) Will using solely XML be sufficient to code an app? Does it require working in partnership with Java?
2) Does anyone know of any books, recommended books of course, that break everything down for you step-by-step?
Android Developer site very good to give you all ideas. Start from Hello, World
1.) Not at all. XML is ONLY used for the layouts.
2.) There are a few books out there that I'm sure someone will come along and recommend, but I've found the tutorials here to be the best start.
In your case, I'd look at AppInventor which allows you to create small Apps without coding (at least that's what it says, haven't used it yet myself)
1) No, you can use XML for interface, but you can't write an Android app in XML :) You are not required to work with Java, but Android language is based on Java, so knowing Java is an advantage while learning to code.
2) Did you installed Eclipse and the plugin for Android?
The Android Training is pretty useful, and I've learnt a lot from the tutorials and the sample code provided there. (The Notepad app is way more complex than the Hello World tutorial ;)!).
Also, take a look at the answers on that question: How can I learn Android?

Android: Active project attempting to improve the GUI design process?

I'm not looking for a mock up tool, I'm looking for a reasonable GUI design tool for the final product in the style of Apple's Interface Builder. Droid Draw is buggy, out of date and inaccurate in my experience. Using the Eclipse plug in to do a complex layout makes going to the dentist seem fun. I'd even settle for hand-coding CSS pixel coordinates over the current model. Is the solution found here: http://andrdev.blogspot.com/2010/01/gui-designer.html the best, or have one of you ninjas found something else? If there is an actively developed project that isn't ready for show yet, I'd like to know that as well.
I don't see why you'd want something like this (especially the tool you posted a link to). That would mean learning a whole new language just to use that tool. Why not learn the XML definitions directly? Yes, it's a relatively steep learning curve but once you're up to speed you'll see it's great. Also, doing XML by hand will allow you to optimize your layouts a lot (there are a few articles out there on how to do that).
As to the Eclipse plugin, I find it quite awesome, although I never use it directly. I don't add/remove/edit elements with it. I write my XML code and then test it with the plugin so I don't have to recompile the app > upload it on the emulator > run the app > go through all the activities to get to the one I'm editing right now, just to see that I need to add a little more padding.
Also, in general, it's best to use the tools you are given. Third party tools are very likely to become outdated, discontinued, deprecated, ...
In conclusion: do it the right way. Write your XML by hand. Use the Eclipse plugin as a convenience tool.

Categories

Resources