我想创建一个音乐流应用程序。 到目前为止,它工作得很好。 我使用的TextView没有从按钮内点击点击
方便的方法,以制备无限流(24×7的mp3流)。 它在这个调用上挂了几秒钟,我把它整齐地塞进我的startPlaying()方法中。 该按钮不会显示它被点击,直到流开始播放之后,用户才开始想知道他们是轻按了按钮还是错过了。 所以我想更新一个TextView标签旁边的按钮,说“等...”或“缓冲”等,然后在流开始后清除它,所以用户知道他们按下按钮确定。 即使我在调试中经过这一步,标签不会更新,直到onClick完成。我可以注释掉清除标签文本的最后一行,并可以看到它设置为“缓冲...”确定。但只有在它退出onClick后。这是使用媒体播放器create()方法的限制吗?
final Button startbutton = (Button) findViewById(R.id.Button01);
this.tvBuffering = (TextView) findViewById(R.id.tvBuffering);
startbutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
tvBuffering.setText("Buffering...");
//do something like invalidate() here??
startPlaying(); //blocks here for a few seconds to buffer then plays.
tvBuffering.setText(" "); //clear the text since it's playing by now.
}
});
太棒了!太感谢了! –