Android Doc for iOS developers

1 Android and iOS analogy

Android   iOS

Fragment   View

Activity   UIViewController

Shared Preferences   NSUserDefaults

SQLite   Core Data

listen for events    delegate

xml layout   xib

AndroidManifest.xml   Project-Info.plist

activity stack   UINavigationController

Intent UIViewController init()

Adapter   data source and delegate

getView is very similar to cellForRowAtIndexPath:.

Another similarity you’ll notice is a pattern for reusing views, similar to iOS.

 

2 Fragments are mini controllers that can be instantiated to fill activities.

Also note that fragments do not have their own contexts and they rely heavily on activities for their connection to the application’s state.

 

Tablets are a great fragment use case example: you can place a list fragment on the left and a detail fragment on the right.

Fragments allow you to break up your UI and controller logic into smaller, reusable chunks.

 

Fragments are the new way of structuring apps on Android, just like UICollectionView is the new way of structuring list data instead of UITableView for iOS. While it is initially easier to avoid using fragments and instead use nothing but activities, you could regret this decision later on. That said, resist the urge to give up on activities entirely by swapping fragments on a single activity – this can leave you in a bind when wanting to take advantage of intents and using multiple fragments on the same activity.

 

reference: https://www.objc.io/issues/11-android/android_101_for_ios_developers/

 

3 ListView

ListViews are the closest approximation to UITableView on Android

 

Just like UITableView has a helper view controller, UITableViewController, ListView also has a helper activity, ListActivity, and a helper fragment, ListFragment

 

4 Layout

The primary structure that you will deal with will be subclasses of ViewGroupRelativeLayout, LinearLayout, and FrameLayout are the most common.

Layout Tips

  • Always work in dp (density-independent pixels) instead of pixels directly.
  • Don’t bother nudging items for layouts in the visual editor – often the visual editor will put individual points of spacing on objects instead of adjusting the height and width as you might like. Your best bet is to adjust the XML directly.

If you ever see the fill_parent value for a layout height or width, this value was deprecated years ago in API 8 and replaced with match_parent.

 

Reference:

Getting Started with Android Development (Ray Wenderlich)

Android 101 for iOS Developers

An iOS Developer Takes on Android

Advertisements

About liyao13

Yao Li is a web and iOS developer, blogger and he has a passion for technology and business. In his blogs, he shares code snippets, tutorials, resources and notes to help people develop their skills. Donate $5 to him for a coffee with PayPal at About Me page and read more professional and interesting technical blog articles. Follow him @Yaoli0615 at Twitter to get latest tech updates.
This entry was posted in CS Research&Application, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s