我对 Java 比较陌生,希望能得到一些帮助。我正在尝试在片段中使用方法(handleSelection 方法),但该方法似乎不起作用,而是突出显示未使用该方法。
public class TrendingFragment extends Fragment {
Song selectedSong;
public void handleSelection(View view)
{
String resourceId = AppUtil.getResourceId(getActivity(),view);
selectedSong = songCollection.searchById(resourceId);
AppUtil.popMessage(getActivity(), "Streaming song: " + selectedSong.getTitle());
sendDataToActivity(selectedSong);
}
public void sendDataToActivity (Song song)
{
Intent intent = new Intent(getActivity(), PlaySongActivity.class);
intent.putExtra("id", song.getId());
intent.putExtra("title", song.getTitle());
intent.putExtra("artist", song.getartist());
intent.putExtra("fileLink" ,song.getFileLink());
intent.putExtra("coverArt", song.getCoverArt());
startActivity(intent);
}
private SongCollection songCollection = new SongCollection();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.fragment_trending, container, false);
return v;
}
}
德玛西亚99
相关分类