Porting a TabViewController based app to Android - android

I am in the process of porting over an iOS application to the Android platform. I have no experience in this platform and would like to ask for some advice on how best to structure the app. On the iOS end, the app is simply a tabviewcontroller with 3 tabs, each with a list view. The list view is populated with a http request to a server requesting user ids and user information. How can i get these components working in Android?

Well, you'll need a few components to get it done.
If you know nothing at all about android, before getting started I recommend you learn the basic about layouts, activities and views following this well written guide (Follow the getting started section):
http://developer.android.com/training/index.html
For starters, you need your UI layout to have tabs, I recommend following this guide:
http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
Second, you'll need to have a ListView component in each tab. Use this simple xml to define a ListView component in your layout XML files (this example will take up the entire tab):
<ListView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listview"
</ListView>
And here's a good guide that explains how to fill the ListView with data using an Adapter:
http://developer.android.com/guide/topics/ui/declaring-layout.html#AdapterViews
Third, you'll need a component that downloads the information from the web server and updates the Adapter. This must be on a separate thread, you're not allowed to do network operations on the UI thread in android (to keep the UI available for user actions). You can use AsyncTask to do that, following this guide:
http://developer.android.com/training/basics/network-ops/connecting.html
Now, how you parse the data is up to you, but if possible I recommend using JSON and the JSONObject class which makes parsing pretty easy.
Good luck and welcome to android!

Related

How to Create Timeline UI on Android

I want to create android application that read RSS feed from some websites. My application should be like this picture below. I don't know how to create timeline UI like this. Should i use webView to create IU like this, or there's any other approach ?
Take a look at Card UI, this could get your job done.
https://developer.android.com/training/material/lists-cards.html
There is no significance of using a webView for a timeline layout. You would (almost) definitely be using a listView or (even better) recyclerView.
Additionally, to comply with new material design guidelines, you can use cardView. see Creating lists and cards.
These are basic design elements. You should at least be familiar with listView implementations if you intend to create such a UI. Here is a nice tutorial about using a listView.
Vogella - Using lists in Android

Create Android Client For Website

As a beginner wanting to become more familiar with the android platform, I wanted to create a web client for a website.
Something similar to https://play.google.com/store/apps/details?id=com.krinsen.javadocreader&hl=en
However, I am confused about how the author created the custom UI for the java docs.
To my understanding, there are 2 ways to do this.
One approach is with WebViews. I quickly prototyped a sample of this but I believe (correct me if I'm wrong) that I can't change the UI of the WebView and will have to view the page from the perspective of a browser. Unfortunately, this does not look very well as the website was not mobile optimized and there are inconsistent spacings and odd whitespace.
The second approach is to manually create each View using the different layouts provided by android (LinearLayout, TableLayout, etc). This should create a more custom mobile experience as I can manually construct how each page will look. However, this seems time-consuming as I will need to manually create a different UI page for each page of the website. Also I am confused as to how to pull the data from the website as each new view in the new UI will need the content from the website. Do I need to do HTML parsing to pull the content or is there a better way in the android sdk? What is a good approach that android developers take to extract the different forms of content from a website to redisplay on a android client?
Finally, since I have a very beginner understanding of this situation, am I correct in assuming that most likely the creator of the application mentioned above did something similar to the second approach I mentioned?
What is a good approach that android developers take to extract the different forms of content from a website to redisplay on a android client?
I think the best way is to provide an API for native application. Parsing HTML might look nice untill you need to suppport every change in your HTML page. But if you are not the owner of web-site there is no other choise if only you don't contact owners and ask for an API.

Flex Mobile List

Is there a way to use a Flex Mobile List control like a ASP.NET repeater?
For example a repeater in ASP.NET allows you to have many controls in the itemtemplate that can be bound to a data source. A easier way to understand it is using the Facebook mobile application. I'm wondering how that is created because I can't seem to use a grid or a list to function in that way.
Although I have never used ASP.NET repeaters, I believe you are referring to an ItemRenderer. Each item in the list will display differently, depending on the data provided to it. You can write your own ItemRenderer in either ActionScript or MXML. If you have large and/or complex data in the list, I would recommend using ActionScript. They can be a little tricky at first, but you will get the hang of it. Start out small. Try simply extending a LabelItemRenderer and setting the text value based on the the data object, then expand it from there. Be sure to take a look at some of the great documentation for it here, and here.

Embed HTML into application

I have android application that is written "regular" way. layouts, java, APK.
Now, depending on some factors I want data to be presented differently to different users with different preferences, etc. Doing it using XML layouts will be very problematic in couple of reasons:
Upgrade issue - we have bunch of users and they not good at upgrading.
Hard to maintain and code.
So, I'm toying with idea of "templates" where we can serve templates from server and just use device to generate those.
Web app won't work because our data available offline in case there is no connection.
There is buttons and stuff that user can press to call regular Activities and do things.
I envision something like:
HTML 5 template with {tags} that I will populate from data. I will receive tempaltes and data separately from server. I will merge that data and display on UI.
Now my question is how do I:
Display HTML5 inside Activity
Intercept button push in HTML in my Java code?
Is this bad idea to write something like this?
It sounds reasonable to me. You can use a WebView for displaying the content. Your app can manage a cache of downloaded templates and other content and display it in the web view either from the web site or from the cache if offline.
I think your objections to layouts are offbase. You really might be better off with layouts. Here's why:
Your app can be set to auto-update by users if you do not change permissions. But pushing updates to your app will remain an issue unless your app is entirely web-based. (not a bad approach by the way) But so long as you have a native app, you will need to push updates from time to time.
And as far as being hard to maintain and code, layouts are specifically designed to make this type of customization manageable. You can break pieces of the layout common to different settings into separate files, and add them with includes.
You can use fragments to adapt to a variety of form factors.
You can serve up different layout based on screen size, language, orientation, or any of a wide variety of variables.
Check out some of the series on layout tricks, and get more familiar with being a layout power user. I think in the long run it will save you a lot of effort, assuming you don't switch to making your app a web app instead.
http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
http://developer.android.com/resources/articles/layout-tricks-merge.html
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/
Google: Android Layout Tricks.
Great stuff.
Another benefit: Compiler checking. No broken functionality because a variable or field has the wrong name. Not the case with HTML.
Another benefit: works offline too with no messing around.
And last - you will have a non-trivial amount of work attempting to get this hybrid HTML stuff working the way you want, and then have a very unusual and custom code base that nobody here on Stack Overflow will be able to help you with. Stick with Layouts and there are lots of experts who can help you tackle the stickiest layout puzzles.

Building User Interface in Android - Views vs. XML

I am very new to Android development and, while I get the general premise (and have even built a small application), I have been looking at other developer's source code to get an idea of how to better approach my development for larger projects.
One developer's code is read is basically using both XML layouts and Views for the various parts to the UI (similar to what is being asked in this question). I understand what he is doing, but it seems overly complicated to me. The XML layouts provide functionality already to create responses to actions. (For example, "onClick" is provided for most components in the XML.) Layouts can be generated very easily with the XML.
So, my question is - can I get away with building my entire application using just Activities and XML layouts? Can I choose not to use any Views? (Of course, this is assuming a relatively simple app - think task list or something similar.) Or, am I trying to simplify too much?
The general strategy I use is to push as much as possible into XML. It's a very different way of thinking from some other UI development systems, but it's very cool once you get past the learning curve.
I don't know what you mean by choosing "not to use any Views". Every UI component is a View of some sort. If you mean not using any custom View subclasses, then yes, it is definitely possible. The only reason to create your own custom View classes (and then use them in XML!) is when the stock widgets and views don't do what you want. Since they are quite flexible, this tends to be fairly uncommon (until you start getting into fancy behavior or need custom graphics behavior).
There are two ways for Creating UI for Android Application. They are
Using XML - You can use xml for designing UI targeted for supporting Multiple device. Also XML helps you to create Static components.
Java Code -Generally it's not a good practice to creating UI in java. Its suitable, if you creating a samll application. Its also useful when you want to develop application with dynamic components. If you want to create Dynamic Components in UI, Java code helps you to achieve this.
The Good Approach is to create UI via XML, unless there's no dynamic component needed in the UI. if you need dynamic UI creation then you go custom UI creation i,e., Using Java Code.
Since you are New to Android, i would like you to refer android developer site
I think you misunderstand, XML layouts are just a shortcut for creating views. You end up with the same results at runtime either way. Mix, match, use one or the other, it's up to you.

Categories

Resources