We are beginning to learn Android, converting our iPhone apps over.
There is a rudimentary editor for layouts in Eclipse, but it's not very good. Is there a visual designer that would be on par with the iPhone "Interface Builder" ?
AFAIK there is no such builder yet for Android,
Check out droiddraw and try to make the most out from Eclipse builder, those are the best and only interface builders. Anyway once you get in, you won't spend to much time creating lots of interfaces, as you will reuse them or the inbuilt components like preferencescreen.
When developing and thinking about layouts, think them as they were like HTML layouts.
App Inventor looks interesting, but it's still in beta and you need to request access:
http://appinventor.googlelabs.com/about/
It seems to have a nice interface for building Android UI's and actually generates other code such as networking and database code.
Related
Are there any advancements in this area? I want to be able to write purely functional code on Android in Haskell or similar languages. I've tried some examples with Scala but it seems to be a pain to get started. Are there any other functional JVM languages which I can use to write Android applications?
Edit: functional languages that write native android applications. My mistake about the JVM.
I doubt that you can find anything mature for writing Haskell-like code for Android. You do need to implement Java abstractions which are required by Android API (implement activity, etc.).
But if you really want to write for Android in a purely functional style you can try to implement your business logic in a pure functional language that compiles to JVM and call it from your Java classes. That approach would be much simpler than trying to implement it entirely in pure functional style.
As your language choice, you can try
Frege, it even has a library for android - froid
Eta lang, it is very new and probably nobody has tried to use it for Android yet
I you want a painless solution in terms of Gradle builds etc., you have only two options: Java and Kotlin, of which of course you should choose Kotlin ;)
Kotlin has most of the things you need to write in functional style:
functions as first class citizen
higher-order functions
immutable collections
var and val like in Scala
if-else as a statement
elements of pattern matching (where statement)
tail recursion
and more...
If you also include funKTionale and kotlinx.collections.immutable, you'll have all the functional goodies like: Option, Try, currying, memoization, persistent data structures and so on...
To start with Kotlin just install the latest Android Studio 3 Preview, which already has built-in Kotlin support.
BTW, don't be so polarized into "pure" functional ;) After all, being 100% "pure" means no side-effects, which means your app can't interact with the user ;)
Hope this helps :)
I've never tried it personally, but you can do F# programming using Xamarin.Android (and, I believe, with Xamarin Forms too). You can see the guide here. (It also includes sample code).
As some background, F# is the .NET Framework's functional language. It is derived from ML; in fact, many ML scripts can be compiled almost "directly" as F# (with the caveat that you may have to do some renaming because F# has some additional keywords that ML doesn't have in order to support several .NET-specific extensions).
Xamarin allows for native development for Android, iOS, and Windows phone. Xamarin Forms allows for a single code-base for all three platforms (it's a competitor to Ionic).
One more quick point: Android does not use the JVM, even if you're writing apps in Java. (In fact, Android does not even support all Java 8 features yet). Through Android 4.4 it used Dalvik; after that, it started using Android Runtime.
You could also try using a JVM language like Scala to create a JAR file and create a bindings library for it.
Please also note that you'll end up using at least somewhat of a mixed paradigm - for example, things like Activities are objects, and the XML files used to define an Android screen is, for all practical purposes, declarative. Edit: This last point is slightly debatable - see the comments.
One final possibility: I haven't checked this out too closely, but try also this link for a site claiming you can do Scala in Android.
Between Pure functional and Java, there is a way which is IMO Pragmatic functional. For instance Redux achieves that in the React arena.
My goal is to write an app (Activity) having an immutable state that advanced as a result of interactions is functional.
In the browser you can see that done with elm (Haskel like language which is also web platform)
Since we want an Android app, I opened the Android Studio used the wizard to create and app with Navigaton Drawer Action bar (with Drawer, FloatingActionBar),
Then converted it to use Elm concepts of immutable model functional approach into a working POC based on a small ElmBase class and idioms.
The code is written in Kotlin (JetBrains tool of choice for the JVM).
You can find the app at my GitHub https://github.com/saffih/ElmDroid The sweet spot of that approach is that it leverages Kotlin being strongly typed and the editor does code completions very well,
making lot's of the code completed for me in a way I have never seen before - amazing experience (But it require using idioms like the sealed class and when properly).
We are designing a generic Android application using Xamarin Forms. At the same time, we need some texts that the user enters to be treated a bit differently for some of the customers, ie. run them through a custom transformation.
Instead of having to build a different version of our generic app, it would be great if we could define those transformations as an external dependency, as a pluggable "dll" or a text file with a script, maybe something like MoonSharp.
Does anyone have experience with something similar and how to achieve that in Xamarin Forms?
We did end up using the MoonSharp framework and the Lua scripting in two different projects, one on Xamarin, and another one on a classic windows service C# application. It was a great tool and gets the job done!
recently I attended a talk on Xamarin and we were discouraged from using XAML for our UI design. I recently started mobile development and I would like to know which is the best way to design user-interfaces; doing it programmatically or using XAML?
EDIT 2017 - With XAMLC (XAML-Compiler, read more here) XAML is compiled to IL code at build time so no XAML parsing is involved at runtime anymore. In many cases this makes XAML as fast or very close to coding the UI in code-behind C#. With the latest improvements in XAML compilation, there is now strongly typed data binding (read more here), which is faster and the data binding errors are caught during build time. Some errors in XAML are caught at design time, when you edit the XAML in the Visual Studio XAML editor
I assume you're asking about Xamarin Forms.
It would be interesting if you could mention the reasons why you heard XAML is bad.
The only reason I would think that someone could discourage you from using XAML is performance.
I came across some posts on Xamarin Forms talking about performance issues when using XAML for creating some of the UI with Xamarin Forms.
But given than Xamarin Forms is an early technology, I guess these issues are temporary and will be fixed.
I don't agree declarative UI (XAML) vs coded UI is just a matter of personal taste.
A declarative UI (today is XAML, tomorrow it can be something else) can be a better approach than doing the UI by code, for the following reasons:
It's coincise, it's impersonal. Except few things, XAML looks the same for everyone. You can't say the same thing about actual code, which is more verbose, there are methods called, variables declared, etc.
It's more maintainable. It's easier to read and modify than actual code.
It helps with a clear separation of concerns, between the UI and logic. Same thing can be achieved without XAML, but just by using XAML you are closer to this goal.
Tooling friendly. Unfortunately Xamarin Forms today still doesn't have a previewer or designer, but this is supposed to change There is a XAML Previewer baked-in in Visual Studio when you edit XAML, but it still doesn't work 100%. See more about Xamarin Forms XAML Previewer here and here
I am NOT saying XAML is perfect. But I think it's better than manually coding the UI. XAML uses same C# classes and properties of controls. The XAML syntax is the same with XML, because actually all XAML documents are valid XML documents. XAML is based on XML.
When someone says XAML is bad, I can't help thinking about HTML. Is HTML bad too? Is it better to create HTML elements in Javascript? Obviously it's not.
I know some will say you can't really compare XAML vs HTML because XAML is not as "native" as HTML, but aren't both just related to the presentation layer?
Xamarin (now Microsoft) has some nice introduction to XAML you can read here.
I think developers with native iOS background have a strong inclination towards not using a declarative UI because that's how unfortunately native iOS development mostly works. You are forced to use code to implement different things which are not available in the designer and there's no native declarative UI markup language available(there's one but the format is not public and it's not meant to be directly modified).
You might know this by now but Xamarin Forms is not the only way to build apps with Xamarin. Xamarin != Xamarin Forms.
You can build your UI natively and still share the logic (ViewModels, services, etc). On Android, you can build your UI in the AXML. You will get as closer to the metal you can get with Xamarin with that. But you will need data-binding, so a framework like MvvmCross can help with that.
A very subjective question. Currently the state of Xamarin Forms XAML is similar to early Silverlight in terms of designer support. Similarly, in Visual Studio there has been a lack of Xaml Intellisence though if you use the latest version of Resharper it will provide Intellisense for it.
It can also be frustrating to debug as the command to load the Xaml can cause a crash if the Xaml is invalid. It is still debugable if you catch the exception right there but an error in custom code would be easier to find. Finally I have heard anecdotal evidence that in some cases the XAML is slower but I have not yet confirmed it.
Having said all that, I use XAML. It tends to be the defacto standard in development with languages that have XAML. I also suspect a Xamarin Forms XAML designer will come. Like the early days of Silverlight it is my belief that using XAML may not be the easiest today but it will likely be The best option to prepare your codebase for tomorrow. Once you code your UI you will have quite the task to switch to XAML when the tooling catches up.
But as I stated earlier, a subjective question.
It has been my experience that each tool excels or under performs dependent on the context in which it is used. XAML in Xamarin.Forms is no different.
There are benefits and drawbacks to XAML and the ultimate decision of which to use where needs to be evaluated in a context aware setting.
In a recent project I use both. XAML for the majority of UIs and c# for things like dynamically generated forms. Below is a short and admittedly biased / incomplete list of pros and cons for figuring out which to use where.
XAML Pros -
More clear separation of logic and UI
Easier to read when UI implements styles, triggers, bindings
Easier to add a second version of the UI for a different form factor (tablet/phone/watch)
XAML Cons -
Harder to create a single implementation of custom page generation
Intellisense is not currently supported without add ons or in SAP for Visual Studio
It is not a complete set of XAML like you would get in a WPF project
The only thing I can say with certainty regarding this question is that a blanket statement condemning XAML in forms is non sense.
In my opinion, and it's definitely just an opinion, I prefer to have a almost zero lines of code in a code behind class, where all the definitions of the view will residue in the Xaml file only.
This way, you'll separate the UI from your code logic and will probably have a much cleaner code eventually.
Having said that, Xamarin forms is still very young framework, and many times I've encountered in plugins that don't have support for Xaml, so I had to manipulate the UI using the code behind, but I do it only as a last resort.
I personally prefer to do cross-platform WITHOUT using Xamarin.Forms. I feel like it's easier to create more expressive and pleasing UIs for each platform by using the native UI APIs. Again, as others have said, there is no "better" way to do this, it's all a matter of preference. I personally really enjoy using the iOS interface builder to create my views, and then wire them up to my custom view controllers. This is just what is most comfortable to me, and IMO allows me to create richer, more expressive UIs for my users.
I am rewriting an Android project, and I am stucked and sucked at making the GUI look like the way I wanted it too. It is easily achievable using HTML and CSS, I have done it with PhoneGap, CSS, HTML, JS, but it is kind of slow, so I want to do it native using Java.
(My background is C++ and some web programming stuff)
What I have been encountered so far is that the default GUI builder is not really pretty and I feel frustated almost every the time using it. And people recommend droiddraw in few other questions in Stackoverflow, but it also not resulting in pretty GUI as well.
What I want to have is some flexibility like HTML and CSS and from that I can execute native code.
I believe I can achieve GUIs like from the Facebook or Twitter client easily with HTML and CSS, but if i m going to do native using the SDK, I think I'm gonna need something like 1 month just to do the GUI.
So the questions would be:
Is there any GUI framework for Android SDK ? (More high level then the provided one)
How to render HTML/CSS that allows executing native code on interaction with its element.
Any suggestions welcome for any workflow.
And of course, Open Source solutions are preferable.
There are some projects for some iphone like widgets in android. You can find them seperately mostly in github, so I have not even seen a complete higher level widget library yet. But you can give appcelerator a try. You are writing html,css,js and it compiles to native code. I personally did not used it. It is a free software. Some people are happy with it, and some are not. You should read some experiences before beginning development. http://www.appcelerator.com/
I am an experienced professional programmer who wants to delve into Android programming. I also wish to investigate cross-platform programming using tools like PhoneGap or Titanium.
However, I am a bit in doubt of which learning strategy is best.
One approach is to get a good feeling of the Android environment and later on explore the possibilities of the cross-platform tools.
Another approach is to jump start using say Titanium (which to me looks like the better option of the two mentioned) and then after a while look into the underlying Android building blocks. The reason why this approach seems worth considering is that although I have earned my living on programming for 20 years, I have no experience whatsoever with Java. And the feeling of getting something done has always been encouraging to me.
What do you think? Does option 2 make sense, or would it be more sensible to get an understanding of the Android environment first?
Thanks in advance,
Martin
I think that all depends on what will you develop:
If you want to develop simple interfaces (parsing XML/Json/...) with some forms and nice transitional effects, then Titanium is yours.
However, the most advanced functionalities aim the iOS platform. For example, the augmented reality module or the push notification are not supported for Android.
On the other hand, if you want to develop advanced interfaces (Games for example), then you have no choice: Android SDK is the best way (you can use Flash for Android but it doesn't support very first Android OS versions).
In all cases, you have to understand how the Android platform works.
I had a similar decision to make, although I am not an experienced programmer like you with vast experience , I had no java knowledge and I needed to write an android app for a project in grad school ,and i'd tend to agree with you on which is the better option , although reading the dev guide and grasping the basics will be a must. And like Zakaria says , it also depends on what you plan to develop.
in my case I learnt basic java first , then used the SDK for my project. Its not that big a learning curve actually , I did not find too many problems with the API.