Tìm kiếm Blog nà


Breaking News
Showing posts with label Hướng dẫn lập trình android. Show all posts
Showing posts with label Hướng dẫn lập trình android. Show all posts

Wednesday, August 20, 2014

Hiệu ứng lắc trong android



Tạo project Android:

Bước 1: Add folder đặt tên anim nằm trong thư mục res
add thư mục anim trong res
 Tạo 2 file .xml 
+ cycle.xml để cấu hình "số lần lắc "
+ shake.xml cấu hình hiệu ứng lắc

Bước 2: Sử dụng hiệu ứng lắc
Xây dựng màng hình gồm 1 button và 1 EditText
Code trong main.java


Download source code:  Tại đây
Read more ...

Tuesday, August 19, 2014

Lập trình Android FPT Software Training

Toàn bộ chương trình tranning Android của FPT Software :


Nội dung đào tạo: 
Ngày 1
- Introduce about ADT, SDK, NDK, Android Platform, API
- Application structure, Hello world
- Manifest : permission, application, phiên bản SDK
- Viết ứng dụng ‘Hello world’
- Building and running the activity (Example with button, textview without xml layout)
- Using xml layout
- TextView, Button, ImageView, Checkbox, Toggle, Radio Button
Ngày 2
Bố trí giao diện ứng dụng Android
- Containers, Linear Layout (layout_gravity, gravity, orientation, layout_weight)
- Relative Layout (align, abow, below)
- Table View, ScrollView, Selection View : ListView, GridView, GalleryView, Spinner
Ngày 3
Lập trình widgets: image buttons, progress bar, seekbar…
-      Hứng sự kiện
- Option menu and Context Menu
-      Inflate Xml for Menu
Ngày 4
Nâng cao kỹ thuật bố trí giao diện
- Fancy with Lists : customize adapter
- Using convertView
- Using ViewHolderTabLayout

Ngày 5
Other widgets for showing message : Toast, Dialog, ProgressDialog
- Dealing with thread
- Logic vs UI Thread
- Thread – RunOnUiThread
- AsyncTask (Example : Loading file with asynctask and ProgressBar)
Ngày 6
Intent & Intent Filters
- Intent And Intent Filter (filter for call, view picture, view map, webpage …)
- Activity, Activity for Result. Why and When?
- Activity Life cycle (OnCreate, OnStart, OnResume, OnPause, OnStop, OnDestroy)

Ngày 7
Broadcast- Services
- Bind Service, Application Service, AIDL Service
Lập trình dịch vụ SMS – Telephone
Ngày 8
Lưu trữ trong Android
- Read and Write File (cache, external, internal)
- Preferences
- Make Setting Page with Preferences
- SQLite Database
Ngày 9
Content – Content Provider
- Tạo content provider
- Tạo custom provider
Ngày 10
Viết ứng dụng kết nối dịch vụ web service
- Phương thức REST
- HttpUrlConnection
Phân tích dữ liệu trả về kiểu XML – JSON
Ngày 11
Lập trình đồ họa – hoạt hình
- Vẽ trên Canvas
- Tăng tốc đồ họa
- Lập trình hoạt hình
Ngày 12
Lập trình tương tác đa chạm
- Xử lý tương tác touch, pin, pan, rotate,…
Ngày 13
Lập trình multimedia
- Play audio – video
- JetPlayer
- Chụp ảnh – truy xuất album ảnh
Ngày 14
Tích hợp thông tin địa điểm và bản đồ số
- Location Base Service
- MapView and MapActivity
- Display map & Pin a location in a Map
Ngày 15
Giao tiếp với các cảm biến
- La bàn, cảm biến gia tốc, cảm biến con quay hồi chuyển. Nhận dạng rung lắc thiết bị
- Cảm biến ánh sáng, vị trí…


Slide + Source code demo:
  ▶  Android FPT Software Training :  Tại đây


Read more ...

Saturday, July 5, 2014

Hiển thị HTML cho Android TextView

Hiển thị HTML cho Android TextView
Hiển thị HTML cho Android TextView
DơwnLoad Source Code:



  ▶ Link dơwnload:  Tại đây
Read more ...

Sunday, June 22, 2014

[Huớng dẫn] Tạo Project Androi không cần appcompat_v, Xóa project appcompat_v, Fix lỗi xóa project appcompat_v

Trong phiên bản mới khi nâng cấp, khi tạo 1 project mặc định sẽ có 1 project appcompat_v đuợc tạo kèm. Vấn đề là khi tạo nhiều project android sẽ xuất hiện nhiều project appcompat_v.
Có rất nhiều project appcompat_v ??

Vậy làm sao để xóa bỏ project appcompat_v?
Đầu tiên bạn phải hiểu project appcompat_v chứa gì trong đó, và tại vì sao khi xóa nó thì project ta bị lỗi?
Bài này mình sẽ huớng dẫn sữa lỗi vào sử dụng chung 1 appcompat_v cho cả Workspace .
1. Tìm hiểu về "project appcompat_v"
Các thành phần trong "project appcompat_v": 
- Đơn giản chỉ chứa các thư viện support cho project

Thành phần của appcompat_v 
Mẹo nhỏ khi tạo project bạn nên chon "Empty project" để project chỉ có 1 file .xml và 1 file .Java
Empty project
Vào chọn Proprerties của Project:
Có 2 phần cần lưu ý:
+ "Phiên bản" của app là bản API nào?
+ Library của projecr  -> đây chính là nguyên nhân gây lỗi khi bạn xóa project  appcompat_v
Khi xóa project appcompat_v tuơng ứng của project bạn mới tạo 
-> Xuất hiện lỗi ( thiếu phần support library cho project ) 

Vào chọn Proprerties của Project:
 Lỗi phần  Library của projecr  -> đây chính là nguyên nhân gây lỗi khi bạn xóa project  appcompat_v

 Lưu ý: Phải có ít nhất 1 "project appcompat" để làm thư viện hỗ trợ 
2. Khắc phục lỗi xóa "project appcompat_v"
Buớc 1: Vào chọn Proprerties của Project:
-> Phần  Library của projec -> Chọn Remove

Buớc 2: Vào chọn Proprerties của Project:
-> Phần  Library của projec -> Chọn Add
Chọn 1 "appcompat" đã có sẵn 
-> Lưu ý: Phải có ít nhất 1 "project appcompat" để làm thư viện hỗ trợ 

Chọn Ok và xem kết quả ( Đã fix đuợc lỗi )

Lời kết: Chúng ta chỉ cần để 1 "project appcompat" và sử dụng chung cho các project.
Khi Tạo 1 project mới bạn chịu khó xóa "project appcompat" đựoc tạo mới và làm buớc khắc phục lỗi như trên là ok.
Bài tới mình sẽ huớng dẫn cách quản lý WorkSpace như thế nào cho tốt và hiệu quả ? 
Read more ...

Thursday, April 3, 2014

Bài 3 - Ứng dụng đầu tiên ( Nhập vào 2 số và tính tổng)

Hướng dẫn bởi StudingCoding
Hôm nay mình sẽ hướng dẫn các bạn làm 1 app đơn giản android trên Eclipse
Ứng dụng đầu tiên - Nhập vào 2 số tính tổng
---------------
1. Hướng dẫn thực hiện
[QUOTE]
Bước 1: Cài đặt và cấu hình Eclipse ( các bạn có thể xem lại ở bài viết trước)
Bước 2: Khởi động Eclip vào tạo 1 project
Mình sử dụng máy ảo Gennymotion ( bạn có thể vào xem hướng dẫn cài đặt máy ảo này)
Bước 3: Sau khi tạo xong project ta bắt đầu viết ứng dụng
+ Vào layout để thiết kế giao diện cho ứng dụng trước.
Giao diện gồm có 2 cái nhãn để hiện " Nhập a" "nhập b"
và tương ứng 2 o Edittext để nhập dữ liệu
+ 1 button để xuất kết quả

Các control bạn có thể kéo thả vào hoặc vào file code để code
Đã xong phần giao diện ( các bạn nhớ lưu lại nhé)
Kết quả sẽ xuất ra dưới dạng thông báo nhé!
+ Vào file xử lý để code
      - Ánh xạ các control bên giao diện qua file xử lý
    - xử lý
---> đã code xong
Bước 4: chạy ứng dụng
Vừa chạy ứng dụng báo lỗi " nhập dữ liệu"!
Kết quả k tinh được ( do k có dữ liệu)
đã hết lỗi[/QUOTE]
2.  Demo kết quả:
3. Source code
Code giao diện:
[ code]<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nhập a" />
        >
        <EditText
            android:id="@+id/edta"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|top"
            android:ems="10"
            android:inputType="number" >

            <requestFocus />
        </EditText>
    </TableRow>

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nhập b" />
        >
        <EditText
        android:id="@+id/edtb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top"
        android:ems="10"
        android:inputType="number" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/btnTinh"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:text="Tính" />

    </TableRow>

</TableLayout>[ /code]
Xử lý:
[ code]<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nhập a" />
        >
        <EditText
            android:id="@+id/edta"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|top"
            android:ems="10"
            android:inputType="number" >

            <requestFocus />
        </EditText>
    </TableRow>

    <TableRow>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nhập b" />
        >
        <EditText
        android:id="@+id/edtb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top"
        android:ems="10"
        android:inputType="number" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/btnTinh"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:text="Tính" />

    </TableRow>

</TableLayout>[ /code]
Lưu ý: Bài viết bản quyền của StudingCoding
Read more ...

Bài 2 - Cài đặt máy ảo Android Genymotion

Phần mềm giả lập máy ảo trên Android
[media=youtube]zeA7uhpVplU[/media]
Bước 2:
  • Tải và cài đặt Oracle VirtualBox hoặc có thể tải gói Genymotion có tích hợp sẵn VirtualBox.
  • Cài đặt Genymotion theo các chỉ dẫn trên màn hình.Cụ thể:
  • You'll need the following:
    Installation

    Starting up the app for first time after installation.

    You'll need to log in to download the virtual device

    After logging in, select the virtual device or variant you want to try out.


    Just hit next. :p

    Wait for it to get downloaded.

    Select the virtual device you just downloaded and hit start/play.


    Playing around

    You'll be greeted with this lockscreen.


    #Just for thread's sake  .

    Features

    You can configure battery level.




    You can even set the coordinates/ configure GPS.




    It comes Pre-rooted 


    You can even set custom resolution..


    ADB
    ADB can be used for various purposes like copying a file to VM, installing apps, debugging, etc.

    You'll need the following files :-

    You'll need to connect to VM. VM's IP is 192.168.56.101 (is customizable). Use the following command to connect.

    Connect

    Code:
    adb connect 192.168.56.101
Read more ...
Designed By hoclaptrinhcanban