chloe ong
chloe ong

Reputation: 79

android studio: cannot resolve symbol

I am unable to identify the problem. The songCollection.searchById (songCollection is always underlined red) saying that the symbol cannot be identified even though I already have a SongCollection class.

public void handleSelection(View view) {
    String resourceId = AppUtil.getResourceId(getContext(), view);
    Song selectedSong = songCollection.searchById(resourceId);

    AppUtil.popMessage(getContext(), "Streaming Song: " + selectedSong.getTitle());

    sendDataToActivity(selectedSong);
}

song collection class

public class SongCollection {
   private Song[] songs = new Song[5];

   public SongCollection() {
    prepareSong();
   }

Therefore, I cannot play my application or make my songs clickable

Upvotes: 0

Views: 722

Answers (1)

WS Ayan
WS Ayan

Reputation: 521

May be you did not instantiate SongSelection anywhere like this:

SongSelection songSelection = new SongSelection(); 

Upvotes: 1

Related Questions