本文介绍了制作的MediaController显示不隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用的MediaController播放音乐。我想的MediaController出现,直到返回按钮pssed $ P $。现在,我已经尝试跌破code:
I try to use MediaController to play music.I want the MediaController appear until the "back" button is pressed.Now I have try below code:
MediaController mediaController = new MediaController(this){
@Override
public void setMediaPlayer(MediaPlayerControl player) {
super.setMediaPlayer(player);
this.show();
}
@Override
public void show(int timeout) {
super.show(0);
}
//instead of press twice with press once "back" button to back
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
Activity a = (Activity)getContext();
a.finish();
}
return true;
}
};
但它仍然一波未平同时的MediaController可见。当出现的MediaController触摸屏,的MediaController将隐藏。我也已经尝试以下code:
But it still one trouble while the MediaController visible.When the MediaController appear touch the screen, the MediaController will hide.I also already try below code:
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("screen","touch");
return true;
}
但没有奏效。该字符串没有在logcat中显示。任何人有想法办呢?
But it did not work.The string did not show in Logcat.Anyone has idea to do it?
推荐答案
覆盖此方法也在里面媒体控制器
Override this method also inside media controller
@Override
public void hide() {
// TODO Auto-generated method stub
super.show();
}
这篇关于制作的MediaController显示不隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!