B6: Time to coding. Đi tới src\at.exam tạo một class mới là CustomViewGroup với nội dung sau: Mã: package at.exam;

Similar documents
B3: Bên khung Package Explore bên trái đi tới thư mục res, bạn sẽ thấy có 3 thư mục con:

B5: Time to coding. Tới thư mục src/example.java và thay đổi nội dung file như sau: Mã: package at.exam;

Cụ thể những công việc mà AndroidManifest.xml thực hiện: - Đặt tên cho Java package của ứng dụng.

B9: Việc cuối cùng cần làm là viết lại Activity. Tới Example.java và chỉnh sửa theo nội dung sau: Mã: package at.exam;

Time Picker trong Android

Hướng dẫn cài đặt FPT

Entity Framework (EF)

TÀI LIỆU THỰC HÀNH MÔN CƠ SỞ DỮ LIỆU NÂNG CAO

Bộ môn HTMT&TT, Khoa Công Nghệ Thông Tin và TT, ĐH Cần Thơ

I. Hướng Dẫn Đăng Nhập:

HƯỚNG DẪN CÁCH SỬ DỤNG WINDOWS MOVIE MAKER

HƯỚNG DẪN CÀI ĐẶT PHẦN MỀM DIỆT VIRUS AVIRA

Chương 5. Network Layer. Phần 1 - Địa chỉ IPv4. Tài liệu : Forouzan, Data Communication and Networking

Internet Protocol. Bởi: Phạm Nguyễn Bảo Nguyên

BÀI 1: VBA LÀ GÌ? TẠO MACRO, ỨNG DỤNG CÁC HÀM TỰ TẠO (UDF), CÀI ĐẶT ADD-INS VBA là gì?

HƯỚNG DẪN SỬ DỤNG ĐẦU GHI H.264 DVR VISION VS (4CH - 8CH - 16CH)

HƯỚNG DẪN SỬ DỤNG HỆ THỐNG CẬP NHẬT CHỨNG THƯ SỐ HOTLINE:

Kỹ thuật thu nhỏ đối tượng trong Design (Layout)

HƯỚNG DẪN SỬ DỤNG PLESK PANEL

CHƯƠNG 2: CÁC ĐẶC ĐIỂM VỀ MÔI TRƯỜNG PHÁT TRIỂN (IDE)

Tài liệu hướng dẫn: Stored Procedure

BELGIUM ONLINE APPOINTMENT

Khối: Cao Đẳng nghề và Trung Cấp Năm 2009

Chương 5. Network Layer 19/09/2016 1

Cài đặt và cấu hình StarWind iscsi trên Windows. iscsi SAN là gì?

Khoa KH & KTMT Bộ môn Kỹ Thuật Máy Tính

Online Appointment System will work better with below conditions/ Hệ thống đặt hẹn online sẽ hoạt động tốt hơn với điều kiện sau đây:

Tình huống 1: PPPoE với Username và Password

Khoa Công Nghệ Thông Tin Trường Đại Học Cần Thơ. Những hỗ trợ tiên tiến khác của SQL. Đỗ Thanh Nghị

STACK và QUEUE. Lấy STACK

Tạo Project với MPLAB

Tạo repository mới. The working tree. The staging index. Lệnh git init tạo một repository loại git. tại thư mục hiện tại: $ git init

Bài Thực hành Asp.Net - Buổi 1 - Trang: 1

CẤU TRÚC DỮ LIỆU NÂNG CAO

Đa ngôn ngữ (Internationalization) trong Servlet

TỔNG QUAN VỀ.NET VÀ C#

1 Bước 1: Test thử kit LaunchPad.

Cập nhật ResultSet trong JDBC

Giáo trình này được biên dịch theo sách hướng dẫn của Sun Light. Vì là hướng dẫn kỹ thuật, trong này những thuật ngữ kỹ thuật bằng tiếng Anh tôi chỉ

Chương 7. Application Layer. Tài liệu : Forouzan, Data Communication and Networking

ĐỌC, GHI XML VỚI C# TRONG ADO.NET --- SỬ DỤNG VISUAL STUDIO

PHÁT TRIỂN ỨNG DỤNG WEB

Nội dung chính của chương. Các công nghệ đĩa cứng Cấu tạo vật lý của đĩa cứng Cấu tạo logic của đĩa cứng Cài đặt đĩa cứng như thế nào?

HƯỚNG DẪN QUẢN TRỊ HỆ THỐNG

Bộ môn MMT&TT, Khoa Công Nghệ Thông Tin và TT, ĐH Cần Thơ

Chương 6. Transport Layer. Tài liệu : Forouzan, Data Communication and Networking

Phần 2. SỬ DỤNG POWERPOINT ĐỂ CHUẨN BỊ NỘI DUNG TRÌNH BÀY

Lab01: M V C Lưu ý: Để thực hành, các bạn phải cài Visual Studio 2013 trở lên mới hỗ trợ MVC5.

HƯỚNG DẪN SỬ DỤNG DỊCH VỤ CDN

Phần 1: Hướng dẫn sử dụng PictureBox tạo Slide Show

HTML DOM - Forms. MSc. nguyenhominhduc

HƯỚNG DẪN SỬ DỤNG NHANH MINDJET MIND MANAGER

BÀI THỰC HÀNH SỐ 1. Quản trị tập tin: 1/ Tạo các thư mục sau: Bài tập thực hành linux Linuxlab. bt1 bt11 bt111. bt121. bt12. bh1 bh11 bh111.

GIẢI THUẬT ĐỊNH TUYẾN (ROUTING ALGORITHM)

LAB IP SLA Bài 1. Bùi Quốc Kỳ ***

1 Radio Button Radio Group, CheckBox, Spinner

BẢO MẬT TRONG SQL SERVER

BÀI TẬP THỰC HÀNH LẬP TRÌNH WINDOWS C#

BÀI 6 LÀM VIỆC VỚI THÀNH PHẦN MỞ RỘNG CỦA CSS3

HỢP ĐỒNG MUA BÁN HÀNG HÓA QUỐC TẾ GV: NGUYỄN THỊ BÍCH PHƯỢNG

Tìm hiểu Group Policy Object và các ví dụ

LẬP TRÌNH WINDOWS FORM VỚI CÁC CONTROL NÂNG CAO (Các control trình bày dữ liệu dưới dạng danh sách)

Các kiểu định địa chỉ họ MSC-51

Tính kế thừa-2. Bởi: Thanh Hiền Vũ. Định nghĩa lại các thành viên lớp cơ sở trong một lớp dẫn xuất:

Lecture 12. Trees (1/2) Nội dung bài học:

GV: Phạm Đình Sắc or

Nhấn nút New để tạo 1 biến mới Trang 17

TÀI LIỆU HƯỚNG DẪN SỬ DỤNG HOSTING PLESK PANEL

HƯỚNG DẪN SỬ DỤNG DỊCH VỤ CDN

HƢỚNG DẪN TRIỂN KHAI KASPERSKY - MOBILE DEVICE MANAGEMENT

Môn Học: Cơ Sở Dữ Liệu 2. Chương 3 LẤY DỮ LIỆU TỪ NHIỀU NGUỒN

METAPOST. 1.1 Cấu trúc file Metapost. 1.2 Cấu trúc trong Preamble. beginfig(...) endfig;... extra_beginfig(...) extra_endfig... begingraph(...

LÂ P TRI NH WEB ASP.NET

SIEMENS INDUSTRIAL NETWORKS

Mô hình dữ liệu quan hệ (Relational data model)

Bài tập lớn số 1. Giả lập bộ định thời

Bài tập căn bản Visual Basic.Net Vòng lặp. txtn. txtketqua. btntinh. txtn. txtketqua. btntinh. Trang 1

dụng một chính sách, điều này giúp dễ dàng quản lý và cung cấp tính năng Load Balancing (cân bằng tải) phục vụ tốt hơn các yêu cầu của tổ chức.

MỤC LỤC. Giáo trình Thiết kế web Trang 1

NHẬP MÔN LẬP TRÌNH KHOA HỌC DỮ LIỆU. Bài 10: Thư viện Pandas (2)

LEECH Chưởng trình Chat bằng c# : Source :

BÀI GIẢNG CHƯƠNG 3 GIAO TIẾP KẾT NỐI SỐ LIỆU

Mạng máy tính - Computer Network: Hệ. Giao thức - Protocol:

Chapter 4 Menus, Functions And Common Dialog

SIMULATE AND CONTROL ROBOT

Exceptions. Outline 7/31/2012. Exceptions. Exception handling is an important aspect of objectoriented. Chapter 10 focuses on:

Cấu hình Router FTTH ---X---

Google Search Engine. 12/24/2014 Google Search Engine 1

Qu n ả tr h ố g t p ậ tin

Dọn "rác" Windows 7 vào dịp cuối năm

[ASP.NET] MVC Framework và ví dụ minh họa

Bài thực hành số 2 QUYỀN và ROLE

LINQ TO SQL & ASP.NET

Bài 10. Cấu trúc liên nối. khác nhau được gọi là cấu trúc liên nối. nhu cầu trao đổi giữa các module.

Kích hoạt phương thức xa (RMI- Remote Method Invocation )

biến Global có thể được áp dụng cho tất cả các extension trong tất cả các context trong Dialplan.

BÀI LAB ĐỔI TÊN DOMAIN

Hỗ trợ giao thức HTTP trong

Mô hình thực thi ASP.NET page Xây dựng Web Form HTML Control và Web Control Bổ sung code vào Page Page Event Life Cycle Postback event

SPEAKING SUPPLEMENTS

Transcription:

B5: Chỉnh sửa file strings.xml trong res\value: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">example 3</string> <string name="work_hint">enter the work here</string> <string name="hour_edit">hour</string> <string name="minute_edit">minute</string> <string name="button_content">add work</string> </resources> B6: Time to coding. Đi tới src\at.exam tạo một class mới là CustomViewGroup với nội dung sau: import android.content.context; import android.view.layoutinflater; import android.widget.checkbox; import android.widget.linearlayout; import android.widget.textview; public class CustomViewGroup extends LinearLayout { public CheckBox cb; public TextView workcontent; public TextView timecontent; public CustomViewGroup(Context context) { super(context);

//Sử dụng LayoutInflater để gán giao diện trong list.xml cho class này LayoutInflater li = (LayoutInflater) this.getcontext().getsystemservice(context.layout_inflater_service); li.inflate(r.layout.list, this, true); //Lấy về các View qua Id cb = (CheckBox) findviewbyid(r.id.check_work); workcontent = (TextView) findviewbyid(r.id.work_content); timecontent = (TextView) findviewbyid(r.id.time_content); Đoạn code trên giúp ta định nghĩa giao diện của custom ViewGroup mới dựa trên file list.xml. Mọi người cũng có thể tạo giao diện bằng code, ko cần sử dụng XML nhưng sẽ phức tạp hơn và mình cũng ko giới thiệu ở đây. B7: Tạo 1 class Work cũng trong at.exam để thể hiện công việc: public class Work { private String workcontent; private String timecontent; private boolean ischecked; { public Work(String workcontent, String timecontent) this.workcontent = workcontent; this.timecontent = timecontent; ischecked = false; public String getcontent() { return workcontent;

public String gettime() { return timecontent; public void setchecked(boolean ischecked) { this.ischecked = ischecked; public boolean ischecked() { return ischecked; Code rất đơn giản nên mình sẽ không chú thích nữa. B8: Chúng ta đã tạo xong custem ViewGroup, bây giờ chính là lúc sử dụng. Tạo 1 class mới tên là ListWorkApdapter trong at.exam: import java.util.arraylist; import android.content.context; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.checkbox; import android.widget.compoundbutton; import android.widget.textview; import android.widget.compoundbutton.oncheckedchangelistener; public class ListWorkAdapter extends ArrayAdapter<Work>{ ArrayList<Work> array; int resource; Context context;

public ListWorkAdapter(Context context, int textviewresourceid, ArrayList<Work> objects) { super(context, textviewresourceid, objects); this.context = context; resource = textviewresourceid; array = objects; //Phương thức xác định View mà Adapter hiển thị, ở đây chính là CustomViewGroup //Bắt buộc phải Override khi kế thừa từ ArrayAdapter @Override public View getview(int position, View convertview, ViewGroup parent) { View workview = convertview; if (workview == null) { workview = new CustomViewGroup(getContext()); //Lấy về đối tượng Work hiện tại final Work work = array.get(position); if (work!= null) { TextView workcontent = ((CustomViewGroup) workview).workcontent; TextView timecontent = ((CustomViewGroup) workview).timecontent; CheckBox checkwork = ((CustomViewGroup) workview).cb; //Set sự kiện khi đánh dấu vào checkbox trên list checkwork.setoncheckedchangelistener(new OnCheckedChangeListener() { @Override

public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { work.setchecked(ischecked); ); //Lấy về nội dung cho TextView và CheckBox dựa vào đối tượng Work hiện tại workcontent.settext(work.getcontent()); timecontent.settext(work.gettime()); checkwork.setchecked(work.ischecked()); return workview; ListWorkAdapter sẽ được sử dụng thay thế cho ArrayAdapter được bind với ListView. Thông thường ArrayAdapter chỉ cho hiển thị String bằng TextView, nhưng với việc kế thừa và override phương thức getview, ta có thể định nghĩa lại hiển thị cho các thành phần của ListView.