亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

查看活動中的視圖

查看活動中的視圖

慕的地8271018 2023-05-10 17:46:44
我正在努力使我的活動正常進行,但方法出現問題nextSong()。它的最后一行playorPauseMusic()有一個錯誤:-playoyPauseMusic (View) in PlaySongActivity cannot be applied to ()我不太確定問題是什么,但認為是關于(View view). 我是 Java 的新手,所以如果您能詳細說明這個問題,那將有很大幫助。謝謝;)public void playorPauseMusic(View view) {    if (player == null) {        preparePlayer();    }    if (!player.isPlaying()) {        if (musicPosition > 0) {            player.seekTo(musicPosition);        }        player.start();        getSeekBarStatus();        btnPlayPause.setText("PAUSE");        setTitle("Now Playing: " + title + " = " + artist);        gracefullyStopWhenMusicEnds();    } else {        pauseMusic();    }}private void gracefullyStopWhenMusicEnds(){    player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {        @Override        public void onCompletion(MediaPlayer mp) {            nextSong();        }    });}public void stopActivities() {    btnPlayPause.setText("PLAY");    musicPosition = 0;    setTitle("");    player.stop();    player.release();    player = null;}private void nextSong(){    Song nextSong = songCollection.getNextSong(songId);    if (nextSong !=null)    {        songId = nextSong.getId();        title = nextSong.getTitle();        artist = nextSong.getartist();        fileLink = nextSong.getFileLink();        coverArt = nextSong.getCoverArt();        url = BASE_URL + fileLink;        displaySong(title, artist, coverArt);        stopActivities();        playorPauseMusic();    }}
查看完整描述

1 回答

?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

你的方法playorPauseMusic(View view)有一個參數View view。這意味著無論何時調用該方法,都必須提供一個 View 實例作為參數。nextSong()在你調用的方法的最后一行playorPauseMusic()沒有視圖參數,導致你的錯誤

雖然看起來您實際上并沒有使用該參數,但您可以將方法更改playorPauseMusic(View view)playorPauseMusic()


查看完整回答
反對 回復 2023-05-10
  • 1 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號