0

I've been following tutorials and have come up with a way to view music on my device.

String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";

    String[] proj = { MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.DISPLAY_NAME,    

    Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = MediaStore.Audio.Media.DISPLAY_NAME + " ASC";
    musiccursor = getContentResolver().query(uri,proj, selection, null, sortOrder); 

    inputSearch = (EditText) findViewById(R.id.inputSearch);
    musiclist = (ListView)findViewById(R.id.listPage2);
    musiclist.setAdapter(new MusicListAssignPage2.MusicAdapter(getApplicationContext())); 

I now would like to be able to have an EditText where I can do a search for a music so I can find it faster. I followed this tutorial: http://www.androidhive.info/2012/09/android-adding-search-functionality-to-listview/ but I am totally lost in how to apply that to my current app.

    adapter = new ArrayAdapter<String>(this, R.layout.activity_music_list_assign_page2, R.id.inputSearch, proj);
    musiclist.setAdapter(adapter);

    /**
     * Enabling Search Filter
     * */
    inputSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
            // When user changed the Text
            MusicListAssignPage2.this.adapter.getFilter().filter(cs);
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                                      int arg3) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub
        }
    });

I've tried this code above but then my app runs but does not display the songs in my device, just the proj[] string instead of all the songs on my device.

I know I'm not applying this correctly. Any help?

Pam
  • 78
  • 7
  • Please go through this link https://stackoverflow.com/questions/9280965/arrayadapter-requires-the-resource-id-to-be-a-textview-xml-problems – Anil Jun 16 '17 at 07:52
  • Possible duplicate of ["ArrayAdapter requires the resource ID to be a TextView" xml problems](https://stackoverflow.com/questions/9280965/arrayadapter-requires-the-resource-id-to-be-a-textview-xml-problems) – Prerak Sola Jun 16 '17 at 07:58

0 Answers0