Android Basic Development Day 1 Introduction & ADT
Upcoming SlideShare
Loading in...5
×
 

Android Basic Development Day 1 Introduction & ADT

on

  • 887 views

Android Basic Development Day 1 Introduction & ADT

Android Basic Development Day 1 Introduction & ADT
by Eakapong Kattiya
eakkattiya@gmail.ccom
www.ibluecode.com
+66 086-673-2111

Statistics

Views

Total Views
887
Views on SlideShare
887
Embed Views
0

Actions

Likes
0
Downloads
63
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Android Basic Development Day 1 Introduction & ADT Android Basic Development Day 1 Introduction & ADT Presentation Transcript

  • Basic Programmingby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Android applications development processDay 1Day 1 - 4Day 5-6Day 5-6by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • AndroidVersionby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Application Designby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • UI Overview1. Main Action Bar (API 11)2.View Control3. Content Area4. Split Action Bar (API 11)5. Options Menu5by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Fixed Tab SpinnerNavigation DrawersApplication Structureby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Fixed Tabs : Movies ,TwitterFixed Tabs- ต้องการเน้นให้ผู้ใช้เห็นข้อมูลหน้าอื่น ๆ- ใช้เมื่อต้องสลับหน้าจอ(View) บ่อย ๆ- จํานวน Top LevelView ไม่ควรเกิน 3-5by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Scrollable Tabs : Google Play Storeby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Stacked Tabs :You Tubeby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • GmailHolo LightSettingHolo DarkTalk inHolo Light with Darkaction barTheme (ice cream sandwich :API 15)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Metrics and GridButton ~48dpGap ~8 dpSize should be specified in dp (density-independent pixels ) do not use = px (pixel)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • FontFont size should be sp (scale-independent pixels)do not use = pt (point)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • AndroidManifest.xml<uses-sdkandroid:minSdkVersion="11"android:targetSdkVersion="17" /><activityandroid:name="MainActivity"android:label="@string/app_name"android:configChanges = "orientation|keyboard"><!-- android:screenOrientation ="portrait" --><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><uses-permission android:name="android.permission.INTERNET" />by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Styles and Themes<TextView    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:textColor="#00FF00"    android:typeface="monospace"    android:text="@string/hello" /><TextView    style="@style/CodeFont"    android:text="@string/hello" /><?xml version="1.0" encoding="utf-8"?><resources>    <style name="CodeFont" parent="@android:style/TextAppearance.Medium">        <item name="android:layout_width">fill_parent</item>        <item name="android:layout_height">wrap_content</item>        <item name="android:textColor">#00FF00</item>        <item name="android:typeface">monospace</item>    </style></resources>by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • icon nameAsset Type Prefix ExampleIcons ic_ ic_star.pngLauncher icons ic_launcher ic_launcher_calendar.pngMenu icons and Action Bar icons ic_menu ic_menu_archive.pngStatus bar icons ic_stat_notify ic_stat_notify_msg.pngTab icons ic_tab ic_tab_recent.pngDialog icons ic_dialog ic_dialog_info.pngby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Android Drawables (www.androiddrawables.com)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Eclipse ShortcutsCtrl + Shift + Space : Show method parameterFn + Cmd + F11 : RunCmd + i : Correct Code IndentationRotate Device : Fn(F12) + Controlby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Applicationby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Application : Step 1by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Application : Step 2by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Application : Step 3by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Application : Step 4by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create Android Application : Step 5by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Activityby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • ActivitySettingActivityFullscreenActivityLoginActivityby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create New Activity : Step 1by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create New Activity : Step 2by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create New Activity : Step 3by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Create New Activity : Step 4Add 3 Blank Activity- FirstActivity- WebViewActivity- DialogActivityby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Login ActivityAdd New Login Activity-LoginActivity.java-activity_login.xmlby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Settings ActivityAdd New Settings Activity-SettingsActivity.java-activity_settings.xmlby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Menuby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • MenuOptions Menu(< API 10)Action Bar(> API 11)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Menu : edit main.xml<menu xmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:id="@+id/action_settings"android:orderInCategory="100"android:showAsAction="always"android:title="@string/action_settings"/><itemandroid:id="@+id/action_login"android:orderInCategory="90"android:showAsAction="ifRoom"android:title="Login"/><itemandroid:id="@+id/action_about"android:icon="@drawable/ic_launcher"android:orderInCategory="91"android:showAsAction="ifRoom"android:title="About"/></menu>android:showAsAction=["ifRoom" | "never" | "withText" | "always" | "collapseActionView"]by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Menu : Add Custom Menu : MainActivity.java@Overridepublic boolean onCreateOptionsMenu(Menu menu) {getMenuInflater().inflate(R.menu.main, menu);//add custom menumenu.add("Save") .setIcon(android.R.drawable.ic_menu_save) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add("Search") .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu.add("Gallery") .setIcon(android.R.drawable.ic_menu_gallery) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;}by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Menu : edit MainActivity.javapublic boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.action_login: startActivity(new Intent(this, LoginActivity.class)); return true; case R.id.action_about: startActivity(new Intent(this, WebViewActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • MenusFloating context menu Contextual action bar Checkable menu Popup Menuby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • WebViewAdd New Blank Activity-WebViewActivity.java-activity_webview.xmlby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Progress BarProgress barsActivity barprogressBarStyleHorizontal progressBarStyleLargeprogressBarStyleby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • Add Permission :AndroidManifest.xmlWebView : activity_webview.xml<WebViewandroid:id="@+id/webView1"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_centerVertical="true" /><ProgressBarandroid:id="@+id/progressBar1"style="?android:attr/progressBarStyleLarge"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"/>style="?android:attr/progressBarStyle"style="?android:attr/progressBarStyleSmall"style="?android:attr/progressBarStyleLarge"style="?android:attr/progressBarStyleHorizontal"<uses-permission android:name="android.permission.INTERNET"/>by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • WebView : WebViewActivity.javaString urlString = "http://www.ibluecode.com" ;WebView webView = (WebView) findViewById(R.id.webView1);webView.loadUrl(urlString);WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true);final ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar1); webView.setWebViewClient(new WebViewClient(){ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { progressBar.setProgress(0); progressBar.setVisibility(View.VISIBLE); } @Override public void onPageFinished(WebView view, String url) { progressBar.setProgress(100); progressBar.setVisibility(View.GONE); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; }});}by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • WebView : WebViewActivity.javaString urlString = "http://www.ibluecode.com" ;//Intent intent = getIntent();if( intent.getExtras() != null){ urlString = intent.getExtras().get("url").toString() ;}//WebView webView = (WebView) findViewById(R.id.webView1);webView.loadUrl(urlString);WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true);final ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar1); webView.setWebViewClient(new WebViewClient(){@Overridepublic void onPageStarted(WebView view, String url, Bitmap favicon) { progressBar.setProgress(0); progressBar.setVisibility(View.VISIBLE); } @Override public void onPageFinished(WebView view, String url) { progressBar.setProgress(100); progressBar.setVisibility(View.GONE); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; }});}Get Data from Intentby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13