Android music player (5) music search implementation

This is a simple music player project I made in my sophomore year last year: it was written as much as possible to imitate Kugou Music, and the specific functions are as follows:

1: Startup animation: Click to run the program and a two-second video will appear, similar to the startup animation of Kugou Music, very impressive!

2: Login registration interface: Enter the account number and password to check the information to log in!

3: Carousel: Exactly the same as Kugou Music, there is an automatic cycle carousel above the main interface, click on each picture information of the carousel to enter the corresponding specific service, very extra points!

4: Music record turntable, song synchronization progress bar, and music pause/play/continue/up and down song switching!

5: Music search is realized!

6: Play the video column!

7; The layout of the personal information interface is realized, such as feedback, rating, more, gender age nickname, collection, etc.!

The music search implementation code is as follows:

package com.ypc.xiaoxiongmusic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.TextView;

public class tukuActivity extends AppCompatActivity {
    private SearchView searchView;
    private ListView listView;
    private View view;
    private ImageView back; 
            "Hua Chenyu- I care about you", "Hua Chenyu- You have to believe this is not the last day", "Hua Chenyu- Jackdaw Boy", "Hua Chenyu- Qi Tian", "Zhang Yixing- will be fine", "Zhang Yixing- good night", "Zhang Yixing- alone", "Zhang Yixing- mask (Live)", "Zhang Yixing- grandma", "Zhang Yixing- I'm not good","Zhang Yixing- Prayer", "Taeyeon(태연) - Gee (Busking Ver.)(Live)", "Taeyeon(태연) - 만약에(If) (Busking Ver.)(Live)",
    public String[] name={"Tae Yeon (태연) - 들리나요(Can you hear me)","Tae Yeon (태연) - 제주도의푸른밤(Blue Night of Jeju Island)","Tae Yeon (태연) - 그리고하나 (There is one more)", "Tae Yeon (태연) - Rescue Me", "Tae Yeon (태연) - My Love (Duet Ver.)", "Hua Chenyu - I really want to love this world (Live) ", 
            "Hua Chenyu- Dialogue with the Children of Mars", "Hua Chenyu- The King and the Beggar", "Hua Chenyu- Bullfighting (Live)", "Hua Chenyu- Dust in Fireworks", "Hua Chenyu- Madhouse (Live) ","Hua Chenyu- Travel Around", "Hua Chenyu- Looking for", "Hua Chenyu- Boring People", "Hua Chenyu- For Forever", "Hua Chenyu- Mayfly", "Hua Chenyu- We (Live)", "Hua Chenyu - Heterogeneity", 
            "Tae Yeon(태연) - bad guy (Busking Ver.)(Live)", "Tae Yeon(태연) - 기억을걷는시간(Time to Gather Memories) (Busking Ver.)(Live )","Leslie Cheung-I blame you for being too beautiful","Leslie Cheung-left and right hands","Leslie Cheung-at least you (00 Live) (live version)","Leslie Cheung-me"}; 
    public static int[] icons= {R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx 
            ,R.drawable.musicx,R.drawable.musicx,R .drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable .musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx 
            , R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx, R.drawable.musicx ,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx,R.drawable.musicx}; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tuku); 
        searchView = (SearchView) findViewById(R.id.search2);
        listView=findViewById(R.id.lv2);
        listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, name)); 
        listView.setTextFilterEnabled(true); 
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { 
            // Trigger this method when the search button is clicked 
            @Override 
            public boolean onQueryTextSubmit(String query) { 
                return false; 
            } 
            // Trigger this method when the search content changes 
            @Override 
            public boolean onQueryTextChange(String newText) { 
                if (!TextUtils. isEmpty(newText)){ 
                    listView. setFilterText(newText); 
                }else{
                    listView.clearTextFilter();
                }
                return false;
            }
        });
        back=findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
       // tukuActivity.MyBaseAdapter adapter=new tukuActivity.MyBaseAdapter();
       // listView.setAdapter(adapter);
    /*    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=new Intent(tukuActivity.this,Music_Activity.class);//创建Intent对象,启动check
                //将数据存入Intent对象
                intent.putExtra("name",name[position]);
                intent.putExtra("position",String.valueOf(position));
                startActivity(intent);
            }
        });*/
    }
  /*  class MyBaseAdapter extends BaseAdapter {
        @Override
        public int getCount(){return  name.length;}
        @Override
        public Object getItem(int i){return name[i];}
        @Override
        public long getItemId(int i){return i;}

        @Override
        public View getView(int i ,View convertView, ViewGroup parent) {
            View view=View.inflate(tukuActivity.this,R.layout.item_layout,null);
            TextView tv_name=view.findViewById(R.id.item_name);
            ImageView iv=view.findViewById(R.id.iv);
            tv_name.setText(name[i]);
            iv.setImageResource(icons[i]);
            return view;
        }
    }*/

}
效果截图如下:

 

 

Guess you like

Origin blog.csdn.net/Abtxr/article/details/127030591