【问题标题】:When I click the listview button to play the sound on Android [closed]当我单击listview按钮在Android上播放声音时[关闭]
【发布时间】:2023-04-11 06:14:01
【问题描述】:

我想做以下事情;

当您点击图片时,您想要播放音频文件。我查看了互联网上的示例,但找不到答案。我该怎么做?

【问题讨论】:

    标签: android audio android-listview


    【解决方案1】:

    这里是代码

        playButton = (ImageButton)findViewById(R.id.imageButton1);
       MediaPlayer mysong = MediaPlayer.create(this, R.raw.song);
          playbutton.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View arg0) {
    
    
                               mysong.start();
            }
    
        });
    

    【讨论】:

      【解决方案2】:

      使用 MediaPlayer(请参阅 this)。在 ImageView 的 onClick 中,根据您的要求调用 start() 函数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-07
        • 2016-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多