Android Basic Development Day 1 Introduction & ADT

  • 720 views
Uploaded on

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

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
720
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
64
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Basic Programmingby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 2. 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
  • 3. AndroidVersionby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 4. Application Designby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 5. 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
  • 6. Fixed Tab SpinnerNavigation DrawersApplication Structureby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 7. 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
  • 8. Scrollable Tabs : Google Play Storeby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 9. Stacked Tabs :You Tubeby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 10. 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
  • 11. 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
  • 12. 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
  • 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
  • 14. 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
  • 15. 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
  • 16. Android Drawables (www.androiddrawables.com)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 17. 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
  • 18. Create Android Applicationby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 19. Create Android Application : Step 1by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 20. Create Android Application : Step 2by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 21. Create Android Application : Step 3by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 22. Create Android Application : Step 4by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 23. Create Android Application : Step 5by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 24. Activityby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 25. ActivitySettingActivityFullscreenActivityLoginActivityby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 26. Create New Activity : Step 1by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 27. Create New Activity : Step 2by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 28. Create New Activity : Step 3by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 29. 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
  • 30. 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
  • 31. 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
  • 32. Menuby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 33. 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
  • 34. 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
  • 35. 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
  • 36. 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
  • 37. 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
  • 38. 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
  • 39. Progress BarProgress barsActivity barprogressBarStyleHorizontal progressBarStyleLargeprogressBarStyleby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Monday, May 27, 13
  • 40. 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
  • 41. 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
  • 42. 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