đồ án môn lập trình ứng dụng cho các thiết bị di dộng đề tài xây dựng ứng dụng tra cứu bài hát karaoke

12 0 0
Tài liệu đã được kiểm tra trùng lặp
đồ án môn lập trình ứng dụng cho các thiết bị di dộng đề tài xây dựng ứng dụng tra cứu bài hát karaoke

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ĐẠI HỌC DUY TÂNTRƯỜNG KHOA HỌC MÁY TÍNHĐỒ ÁN MÔN LẬP TRÌNH ỨNG DỤNG CHO CÁC THIẾT BỊ DI DỘNGĐề tài:XÂY DỰNG ỨNG DỤNG TRA CỨU BÀI HÁT KARAOKEGiảng viên hướng dẫn: Võ Minh ThôngSinh viên t

Trang 1

ĐẠI HỌC DUY TÂNTRƯỜNG KHOA HỌC MÁY TÍNH

ĐỒ ÁN MÔN LẬP TRÌNH ỨNG DỤNG CHO CÁC THIẾT BỊ DI DỘNG

Đề tài:

XÂY DỰNG ỨNG DỤNG TRA CỨU BÀI HÁT KARAOKEGiảng viên hướng dẫn: Võ Minh Thông

Sinh viên thực hiện : Nguyễn Văn Lưu - 48321

Đà Nẵng ,tháng 12 năm 2023

Trang 2

1 Tổng quan giao diện

- Về giao diện chính, ứng dụng có 3 tab có thể chuyển qua lại.

Tab 1: Tìm kiếm (có thể tìm theo Tên hoặc Mã bài hát)

Trang 3

Tab 2: Danh sách bài hát

Trang 4

Tab 3: Bài hát yêu thích

Trang 5

1 Code cụ thể:- File: activity_main.xml

- File: activity_sub.xml

Trang 6

- File: Listitem.xml

- File: Item.class

Trang 7

- File: myarrayAdapter.java

- public class myarrayAdapter extends ArrayAdapter<Item> { Activity context = null;

ArrayList<Item> myArray = null; int LayoutId;

public myarrayAdapter(Activity context, int

LayoutId,ArrayList<Item>arr) { super(context, LayoutId arr), ; // TODO Auto-generated constructor stub this.context = context;

this.LayoutId = LayoutId; this.myArray = arr; }

@Override

public View getView(int position View convertView ViewGroup , ,

parent) {

// TODO Auto-generated method stub

LayoutInflater inflater = context.getLayoutInflater(); convertView = inflater.inflate(LayoutId, null ;)

Item myItem = myArray.get(position);

TextView tieude = convertView.findViewById(R.id.txttieude);

Trang 8

public void onClick(View view) { int thich = myItem.getThich();

ContentValues values = new ContentValues(); //Cập nhật vào cơ sở dữ liệu

MainActivity.database.update("ArirangSongList", values, "MABH=?", new String[]{myItem.getMaso()}); }

});

tieude.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(View v) { // TODO Auto-generated method stub tieude.setTextColor(Color.RED); maso.setTextColor(Color.RED);

Intent intent1 = new Intent(context, SubActivity.class); Bundle bundle1 = new Bundle();

bundle1.putString("maso", myItem.getMaso());

Trang 9

import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList;

public class MainActivity extends AppCompatActivity { String DB_PATH_SUFFIX = "/databases/"; public static SQLiteDatabase database=null; public static String DATABASE_NAME="arirang.sqlite"; EditText edttim;

ListView lv1 lv2 lv3, , ; ArrayList<Item> list1 list2 list3, , ;

myarrayAdapter myarray1 myarray2 myarray3, , ;

private void addControl() { // TODO Auto-generated method stub list1 =new ArrayList<Item>(); list2 =new ArrayList<Item>(); list3 =new ArrayList<Item>();

myarray1 = new myarrayAdapter(MainActivity.this,

R.layout.listitem, list1);

Trang 10

myarray3 = new myarrayAdapter(MainActivity.this,

R.layout.listitem, list3);

private void addEvents() { // TODO Auto-generated method stub

tab.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override

public void onTabChanged(String tabId) { // TODO Auto-generated method stub

// Sự kiện khi Click vào Button xóa trên Tab Tìm kiếm btnxoa.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(View v) { // TODO Auto-generated method stub edttim.setText( )"";

} }); }

//Hàm thêm bài hát vào Listview trên Tab Yêu thích private void addYeuthich() {

// TODO Auto-generated method stub myarray3.clear();

Cursor c = database.rawQuery("SELECT * FROM ArirangSongList WHERE YEUTHICH = 1", null ;)

// Hàm thêm bài hát vào Listview trên Tab Danh sách bài hát private void addDanhsach() {

// TODO Auto-generated method stub

Trang 11

Item(c.getString( ) c.getString( ) c.getInt( )))1, 2, 6 ;

private void addTim() {

// TODO Auto-generated method stub

edttim.addTextChangedListener(new TextWatcher() { @Override

public void beforeTextChanged(CharSequence s, int start, int

count, int after) { getData(); } @Override

public void onTextChanged(CharSequence s, int start, int

before, int count) { }

private void getData(){

String dulieunhap =edttim.getText().toString(); myarray1.clear();

if (!edttim.getText().toString().equals("")) { Cursor c = database.rawQuery("SELECT * FROM

ArirangSongList WHERE TENBH1 LIKE '"+"%"+dulieunhap+"%"+"' OR MABH LIKE '" "%"+ +dulieunhap+"%" "'"+ , null); c.moveToFirst();

while(c.isAfterLast()==false)

private void processCopy() {

File dbFile = getDatabasePath(DATABASE_NAME); if (!dbFile.exists())

{

try{CopyDataBaseFromAsset();

Toast.makeText(this, "Cap nhat du lieu thanh cong!", Toast.LENGTH_LONG).show();

}

catch (Exception e){

Trang 12

} } }

private String getDatabasePath() {

return getApplicationInfo().dataDir DB_PATH_SUFFIX+ + DATABASE_NAME;

}

public void CopyDataBaseFromAsset() { // TODO Auto-generated method stub try {

InputStream myInput;

myInput = getAssets().open(DATABASE_NAME); // Path to the just created empty db

String outFileName = getDatabasePath(); //if the path doesn't exist first, create it File f = new File(getApplicationInfo().dataDir + DB_PATH_SUFFIX);

if (!f.exists()) f.mkdir();

//Open the empty db as the output stream

OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile

byte[] buffer = new byte[1024];

Ngày đăng: 25/04/2024, 16:17

Tài liệu liên quan