Sunday, November 15, 2015

Tạo sự kiện checked Item cho ListView

package net.trongtam.appqlnv;

import android.app.Activity;

import android.os.Bundle;

import android.util.SparseBooleanArray;

import android.view.View;

import android.widget.ArrayAdapter;

import android.widget.Button;

import android.widget.ListView;

import android.widget.Toast;



public class MainActivity extends Activity {

    ListView myListView;

    Button getChoice;

    String[] listContent = {

            "January",

            "February",

            "March",

            "April",

            "May",

            "June",

            "July",

            "August",

            "September",

            "October",

            "November",

            "December"
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        myListView = (ListView)findViewById(R.id.list);

        getChoice = (Button)findViewById(R.id.getchoice);

        ArrayAdapter<String> adapter

                = new ArrayAdapter<String>(this,

                android.R.layout.simple_list_item_checked,

                listContent);


// chọn chế độ checked item cho ListView. Gồm CHOICE MODE MULTIPLE và CHOICE MODE SINGLE
        myList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        myList.setAdapter(adapter);

        getChoice.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View v) {

                // TODO Auto-generated method stub

                String selected = "";

                int cntChoice = myList.getCount();
 
// lấy ra mảng các item được checked
                SparseBooleanArray sparseBooleanArray = myList.getCheckedItemPositions();

                for(int i = 0; i < cntChoice; i++){

                    if(sparseBooleanArray.get(i)) {

                        selected += myList.getItemAtPosition(i).toString() + "\n";

                    }

                }

                Toast.makeText(MainActivity.this,

                        selected,

                        Toast.LENGTH_LONG).show();

            }});

    }

}

Monday, November 9, 2015

Quản lý công việc


Class MainActivity: 
 
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class MainActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener{
    EditText edtCongViec, edtNoiDung;
    TextView NgayHT, GioHT;
    Button btnDate, btnTime, btnThem;
    ListView listCongViec;
    ArrayList<JobInWeek> arrCongViec = new ArrayList<JobInWeek>();
    ArrayAdapter<JobInWeek> adapter;
    String congviec, noidung;
    Date dateFinish, timeFinish;
    Calendar cal;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getControl();
        TimeDateDefault();
    }

    public void getControl(){
        edtCongViec = (EditText)findViewById(R.id.edtCongViec);
        edtNoiDung = (EditText)findViewById(R.id.edtNoiDung);
        NgayHT = (TextView)findViewById(R.id.tvDate);
        GioHT = (TextView)findViewById(R.id.tvTime);
        btnDate = (Button)findViewById(R.id.btnDate);
        btnTime = (Button)findViewById(R.id.btnTime);
        btnThem = (Button)findViewById(R.id.addCongViec);
        listCongViec = (ListView)findViewById(R.id.listCongViec);
        btnDate.setOnClickListener(this);
        btnTime.setOnClickListener(this);
        btnThem.setOnClickListener(this);
        adapter = new ArrayAdapter<JobInWeek>(MainActivity.this, android.R.layout.simple_list_item_1, arrCongViec);
        listCongViec.setAdapter(adapter);
        listCongViec.setOnItemClickListener(this);
        listCongViec.setOnItemLongClickListener(this);

    }

    public void TimeDateDefault(){
        cal = Calendar.getInstance();
        SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy");
        NgayHT.setText(sdfDate.format(cal.getTime()));
        SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm");
        GioHT.setText(sdfTime.format(cal.getTime()));
        dateFinish = cal.getTime();
        timeFinish = cal.getTime();
    }
    // hàm Dialog set ngày hoàn thành    public void DialogDate(){
        cal = Calendar.getInstance();
        int nam = cal.get(Calendar.YEAR);
        int thang = cal.get(Calendar.MONTH);
        int ngay = cal.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog picDate = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
            @Override            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                NgayHT.setText(dayOfMonth+"/"+(monthOfYear+1)+"/"+year);
                cal.set(year, monthOfYear, dayOfMonth);
                dateFinish = cal.getTime();
            }
        }, nam, thang, ngay);
        picDate.show();

    }
    // hàm Dialog set giờ hoàn thành    public void DialogTime(){
        cal = Calendar.getInstance();
        int gio = cal.get(Calendar.HOUR_OF_DAY);
        int phut = cal.get(Calendar.MINUTE);
        TimePickerDialog picTime = new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() {
            @Override            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                GioHT.setText(hourOfDay+" : "+minute);
                cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
                cal.set(Calendar.MINUTE, minute);
                timeFinish = cal.getTime();
            }
        }, gio, phut, false);

        picTime.show();

    }

    public void NoiDungvaCongviec(){
        congviec = edtCongViec.getText().toString();
        noidung = edtNoiDung.getText().toString();
        edtCongViec.setText("");
        edtNoiDung.setText("");
        edtCongViec.requestFocus();
    }

    @Override    public void onClick(View v) {
        if(v==btnDate){
            DialogDate();
        }

        if(v==btnTime){
            DialogTime();
        }

        if(v==btnThem){
            NoiDungvaCongviec();
            JobInWeek cv = new JobInWeek(congviec, dateFinish, noidung, timeFinish);
            arrCongViec.add(cv);
            adapter.notifyDataSetChanged();

        }
    }

    @Override    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(MainActivity.this, arrCongViec.get(position).getNoiDung(), Toast.LENGTH_LONG).show();
    }

    @Override    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        final int i = position;
        AlertDialog.Builder a = new AlertDialog.Builder(MainActivity.this);
        a.setTitle("Câu hỏi");
        a.setMessage("Xóa công việc này?");
        a.setPositiveButton("Có", new DialogInterface.OnClickListener() {
            @Override            public void onClick(DialogInterface dialog, int which) {
                arrCongViec.remove(i);
                adapter.notifyDataSetChanged();
            }
        });
        a.setNegativeButton("Không", new DialogInterface.OnClickListener() {
            @Override            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        a.create().show();
        return false;
    }
}
 
 
Class JobInWeek :

package com.example.letrongtam.dialogdatetime;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/** * Created by Le Trong Tam on 09-Nov-15. */public class JobInWeek {
    private String tenCongViec;
    private String noiDung;
    private Date DateFinish;
    private Date TimeFinish;

    public JobInWeek(String tenCongViec, Date dateFinish, String noiDung, Date timeFinish) {
        this.tenCongViec = tenCongViec;
        DateFinish = dateFinish;
        this.noiDung = noiDung;
        TimeFinish = timeFinish;
    }
    public JobInWeek(){
        super();
    }

    public String getTenCongViec() {
        return tenCongViec;
    }

    public void setTenCongViec(String tenCongViec) {
        this.tenCongViec = tenCongViec;
    }

    public Date getDateFinish() {
        return DateFinish;
    }

    public void setDateFinish(Date dateFinish) {
        DateFinish = dateFinish;
    }

    public String getNoiDung() {
        return noiDung;
    }

    public void setNoiDung(String noiDung) {
        this.noiDung = noiDung;
    }

    public Date getTimeFinish() {
        return TimeFinish;
    }

    public void setTimeFinish(Date timeFinish) {
        TimeFinish = timeFinish;
    }

    public String getDateFormat(Date d)
    {
        SimpleDateFormat dft=new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
        return dft.format(d);
    }

    public String getHourFormat(Date d)
    {
        SimpleDateFormat dft=new                SimpleDateFormat("HH:mm", Locale.getDefault());
        return dft.format(d);
    }
    @Override    public String toString() {
        return getDateFormat(DateFinish)+"  "+ getHourFormat(TimeFinish)+"  "+tenCongViec;
    }
}


Main XML:  
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">
    <TextView        android:id="@+id/tvQuanLyCV"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:gravity="center"        android:text="Quản lý công việc hàng tuần"        android:textColor="#fff"        android:background="#b71aff"/>
   <TableLayout       android:id="@+id/tablelayout"       android:layout_width="match_parent"       android:layout_height="wrap_content"       android:layout_marginTop="10dp"       android:layout_marginLeft="5dp"       android:layout_marginRight="5dp"       android:stretchColumns="1">
       <TableRow>
           <TextView               android:id="@+id/tvCongViec"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Công việc:"/>
           <EditText               android:id="@+id/edtCongViec"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:layout_span="2"/>
       </TableRow>
       <TableRow>
           <TextView               android:id="@+id/tvNoiDung"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Nội dung:"               />
           <EditText               android:id="@+id/edtNoiDung"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:layout_span="2"/>
       </TableRow>
       <TableRow>
           <TextView               android:id="@+id/tvNgayHienThi"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Ngày hoàn thành"/>
           <TextView               android:id="@+id/tvDate"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:gravity="center"/>
           <Button               android:id="@+id/btnDate"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Date"               android:textAllCaps="false"/>
       </TableRow>
       <TableRow>
           <TextView               android:id="@+id/tvGioHoanThanh"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Giờ hoàn thành:"/>
           <TextView               android:id="@+id/tvTime"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:gravity="center"/>
           <Button               android:id="@+id/btnTime"               android:layout_width="wrap_content"               android:layout_height="wrap_content"               android:text="Time"               android:textAllCaps="false"/>
       </TableRow>
   </TableLayout>
    <TextView        android:layout_width="match_parent"        android:layout_height="2dp"        android:background="#32c92727"/>
    <Button        android:id="@+id/addCongViec"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Thêm"        android:layout_gravity="center"        android:layout_margin="5dp"/>
    <TextView        android:id="@+id/tvDsCongViec"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="Danh sách công việc"        android:gravity="center"        android:background="#b71aff"        android:textColor="#fff"/>
    <ListView        android:id="@+id/listCongViec"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginRight="5dp"        android:layout_marginLeft="5dp"></ListView>
</LinearLayout>

Wednesday, March 26, 2014

Phần mềm camera

phần mềm xem camera trên điện thoại:

Cam vivotek:
          - iviewer vivotek lite (iphone, ipad)
          - ... máy tính
Đầu ghi VDTech:
          - CMS VDtech ( máy tính)
          - vMEyesuper  (iphone, ipad port 34567 )
Đầu ghi Vantech:
          -  7777 (PC)
          -  vmeye (8888)
Đầu ghi Avtech
         - ...
         -  EagleEyes lite (androi, iphone, ipad ; port 80)
Đầu ghi Questek:
• Dòng đầu ghi QTD-6100 Series
- Trên iPhone, điện thoại Android: vMeyeSuper (port: 34567)
- Trên iPad, máy tính bảng Android: vMeyeSuperHD (port: 34567)
- Các hệ điều hành còn lại: vMeye (port: 34599)
• Dòng đầu ghi QTD-6204 (từ tháng 1/2013 trở về trước)
- Tất cả các điện thoại và máy tính bảng: Naway hoặc Naway+ (port: 8888)
• Dòng đầu ghi QTD-6200 Series (từ tháng 1/2013 tới nay)
- Tất cả các điện thoại và máy tính bảng: IMSeye (port: 8000)
• Dòng đầu ghi QTD-6300 Series
- Tất cả các điện thoại và máy tính bảng: iWatch DVR II (hoặc Bubo Bubo) (port: 80)
- Điện thoại hệ điều hành đời thấp như iPhone 3G hoặc 2G: ScDVR (port: 80)
• Dòng đầu ghi QTX-6400 Series
- Trên iPhone, điện thoại Android: SuperlivePro (port: 80)
- Trên iPad, máy tính bảng Android: SuperliveHD (hoặc SuperCMS) (port: 80)
• Dòng đầu ghi QTD-6604, QTD-6604i, QTD-6608, QV-6708
- Tất cả các điện thoại và máy tính bảng: Castillo Player, Castillo Player+ (Chỉ dùng cho firmware verison V2.1_0104),
• Dòng đầu ghi QTD-6616, QV-6716
- Tất cả các điện thoại và máy tính bảng:  Cplayer, Cplayer+

Friday, March 7, 2014

Run / control userpasswords2
-> uncheck

Thursday, December 12, 2013

Hình hài của mẹ cha cho
Trí khôn đời dạy, đói no tự mình
Sang hèn trong kiếp nhân sinh
Buồn vui sướng khổ thường tình thế thôi
Không hơn thì cũng bằng người
Cho thiên hạ khỏi ai cười ai khinh.
Có chí thì ham học
Thiếu chí thì ham chơi
Trí khôn tạo nên người
Đức nhân tìm ra bạn
Thành đạt nhờ chí sáng
Danh rạng nhờ đức dày
Làm nên nhờ có thầy
Đủ đầy nhờ có bạn
Gái ngoan nhờ đức hạnh
Trai mạnh nhờ lực cường
Tươi đẹp lắm người thương
Lực cường nhường kẻ mạnh
Dễ thích nghi thì sống
Biết năng động thì nên
Đủ sức bền thì thắng
Biết mình khi hoạn nạn
Hiểu bạn lúc gian nguy
Nghèo hèn bởi tự ti
Ngu si vì tự phụ
Đức tài cao hơn phú
Hạnh phúc đủ hơn giàu
Sống trung tín bền lâu
Của rẻ là của ôi
Dùng người tồi sinh vạ
Đẹp lòng hơn tốt mã
Nền nã hơn kiêu kỳ
Thận trọng từng bước đi
Xét suy khi hành động
Hiểu biết nhiều dễ sống
Luôn chủ động dễ thành
Thận trọng trước lợi danh
Giữ mình đừng buông thả
Tránh xa phường trí trá
Tai vạ bởi nể nang
Tài giỏi chớ khoe khoang
Giàu sang đừng kênh kiệu
Học bao nhiêu vẫn thiếu
Hiểu bao nhiêu chẳng thừa
Nhân đức chớ bán mua
Được thua không nản chí
Đủ đức tài bớt lụy
Đủ dũng khí chẳng hàng
Có vợ đảm thì sang
Có bạn vàng thì quý
Đói nghèo vì bệnh sĩ
Quẫn chí dễ làm liều
Tỉnh táo với tình yêu
Biết điều khi yếu thế
Lo việc nhà chớ kể
Tình nghĩa chớ đếm đong
Giữ trọn chữ hiếu trung
Với Tổ tiên Gia tộc
Cây tốt tươi nhờ gốc
Người phú lộc nhờ nguồn
Sống bất nghĩa-tai ương
Tình nghĩa sâu-hạnh phúc
Có tài thì đỡ cực
Đủ sức thì đỡ nghèo
Dốt nát hay làm theo
Hiểu nhiều thường tự lập
Hỏng việc vì hấp tấp
Va vấp bởi vội vàng
Nhà dư của-hiếm con
Nhà lắm người-bạc cạn
Khó gần người quá sạch
Vắng khách tại quá nghèo
Dễ nổi danh-kỵ hiền
Dễ kiếm tiền-khó giữ
Kiếp người là duyên nợ
Lành vỡ lẽ thường tình
Bại thành bởi trí lực
Thời gian đừng uổng phí
Thời cơ chớ bỏ qua
Biết suy nghĩ sâu xa
Vững vàng khi thành bại
Cần học và hành mãi
Sẽ gặt hái thành công
Cảnh giác với lời khen
Bình tâm nghe lời trách
Quá nghiêm thì ít bạn
Dễ dãi bạn khinh nhờn
Không hứa hão là khôn
Không tin xằng ít vạ
Làm ơn đừng mong trả
Được ơn nhớ đừng quên
Nhu nhược bị ép chèn
Quá cương thường bị gãy
Cái quý thì khó lấy
Dễ thấy thường của tồi
Sống bất lương-tù ngục
Phải cầu xin là nhục
Phải khuất phục là hèn
Hay đố kỵ-nhỏ nhen
Hay ép chèn-độc ác
Lắm gian truân càng sáng
Nhiều hoạn nạn càng tinh
Với mình: phải nghiêm minh
Với chúng sinh: nhân ái
Đang thắng phòng khi bại
Gặt hái phòng mất mùa
Thói quen thường khó chừa
Say sưa thường khó tỉnh
Sống ỷ lại-ăn sẵn
Hay đua đòi-hoạn nạn
Quá dễ hay tai ương
Gia đình trọng yêu thương
Sống nhịn nhường-hỉ hả
Thiếu tình thương-man trá
Dẫu vàng đá cũng tan
Biết dạy dỗ -con ngoan
Chịu bảo ban-con giỏi
Tinh khôn nhờ học hỏi
Cứng cỏi nhờ luyện rèn
Sống vì nhau dễ bền
Rèn con từ lúc nhỏ
Khuyên vợ lúc mới về
Muốn hiểu cần lắng nghe
Thích khoe thường trí cạn
Sống dựa dẫm-ngu đần
Sống bất cần phá sản
Phận bạc-dễ bán mình
Kẻ tồi chơi xấu bạn
Khốn nạn quên mẹ cha
Tốt đẹp hãy bày ra
Xấu xa nên che lại
Có ích thì tồn tại
Có hại sẽ diệt vong
Nhiều tham vọng-long đong
Lắm ước mong-lận đận
Hay vội vàng-hối hận
Quá cẩn thận-lỡ thời
Biết được người là sáng
Hiểu được bạn là khôn
Khiêm tốn là tự tôn
Kiêu căng là tự sát
Hứa trước thường khó đạt
Hèn nhát thì khó thành
Thù hận bởi lợi danh
Tranh giành bởi chức vị
Giàu sang hay đố kỵ
Tài trí sinh ghét ghen
Tham giàu thì cuồng điên
Tham quyền thì độc ác
Vì tiền dễ tan nát
Vì tình nghĩa bền lâu
Người hiểu-nói trọn câu
Kẻ dốt tâu phách lối
Có quyền thì hám lợi
Có tội thường vun xoe
Khờ dại hay bị lừa
Nói bừa hay vạ miệng
Đa ngôn thì tai tiếng
Ngậm miệng dễ được tin
Hám lợi hay cầu xin
Hám quyền hay xu nịnh
Tham quan thường bất chính
Xu nịnh thường gian tà
Lười biếng hay kêu ca
Thật thà hay oan trái
Thẳng thắn hay bị hại
Thông thái hay bị lừa
Chiều con quá con hư
Tiền của dư con hỏng
Giàu mạnh thường thao túng
Nghéo vụng hay theo đuôi
Người tài giỏi-khó chơi
Kẻ chay lười khó bảo
Tham tân thì đắc đạo
Mạnh bạo-việc dễ thành
Quân tử thì trọng danh
Tiểu nhân thường trọng lợi
Bất tài hay đòi hỏi
Lọc lõi khó khiêm nhường
Tình nghĩa thường khó quên
Nợ nhân duyên khó trả
Khó thuần phục kẻ sĩ
Khó phòng bị tướng tài
Biết chấp nhận-thảnh thơi
Hay hận đời-đau khổ
Của quý thường khó giữ
Con cầu thường khó nuôi
Mấy lời để suy ngẫm./.

Sunday, November 3, 2013

Xử lý lỗi viết chữ in hoa

 
mở Unikey, kích vào "Mở rộng", đánh dấu chọn vào mục "Luôn sử dụng clipboard cho Unicode" và chọn lại bảng mã là "Unicode tổ hợp"

Saturday, November 2, 2013

Yến ơi yến sẽ gọi bầy
Ríu rít đêm ngày cho Bác ngủ ngon
Một đời vì nước vì non
Tấm gương sáng ấy mãi còn bền lâu
Người xa khóm cúc bụi ngâu
Về đây nghe tiếng đàn bầu quê hương
Về đây nhớ lại chiến trường
Năm xưa Người đã chỉ đường cho dân
Một quyết định thật khó khăn
Ấy là kéo pháo hoãn binh năm nào
Điện Biên bớt đổ máu đào
Của dân của nước của bao gia đình
Nhãn quan quân sự tài tình
Thần tốc thần tốc minh anh khí trời
Đồng xanh cho đến biển khơi
Hồn thiêng sông núi đất trời hiển linh
Sống tình nên Võ hóa Văn
Thiên tài quân sự Văn thành Võ thôi
Hôn nay mấy chục ngày rồi
Thắp hương tưởng nhớ Bác Người vì dân !