我怎样才能得到一个Android的MediaController从布局XML的出现? [英] How can I get an Android MediaController to appear from layout xml?

查看:90
本文介绍了我怎样才能得到一个Android的MediaController从布局XML的出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了以下XML一个layout.xml文件,但我不能得到的MediaController出现在所有。

I've created a layout.xml file with the following XML, but I can't get the MediaController to appear at all.

<MediaController android:id="@+id/media_controller"
    android:layout_width="fill_parent"
    android:layout_height="200px"
    android:visibility="visible"/>

在code,我可以从code,呼叫显示(),等对它的引用,但它永远不会出现。

In code, I can obtain a reference to it from code, call show(), etc, but it never appears.

我已经注意到了Android开发文档中(<一href="http://developer.android.com/reference/android/widget/MediaController.html">MediaController.html)它指出,使用这个类的方法是编程实例化。,所以也许我是一个dufus,只是需要做一些不同的事情,如不这样做我在做什么。)

I have noticed in the android dev documentation (MediaController.html) that it states, "The way to use this class is to instantiate it programatically.", so maybe I'm a dufus and just need to do something differently such as not do what I'm doing. :)

我可以,如果我编程方式做一次它出现,但我需要它总是出现在屏幕上。我只是愚蠢,或它只是并不意味着通过XML被夸大?

I CAN get it to appear if I do it programmatically, but I need it to always appear on the screen. Am I just being stupid, or is it just not meant to be inflated via XML?

推荐答案

此示例项目

ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);

然后,它会在你挖掘朝着底部边缘的 VideoView

在屏幕上保持它所有的时间方面......我不知道这是可能的。你总是可以创建自己的控制器 - 这里创建自己的弹出半透明控制器的示例项目。这真的不是那么难,你会得到完全控制一切​​,包括安排它是在屏幕上所有的时间。

In terms of keeping it on screen all the time...I don't know if that's possible. You can always create your own controller -- here's a sample project that creates its own pop-up translucent controller. It's really not all that hard, and you get full control over everything, including arranging for it to be on-screen all the time.

这篇关于我怎样才能得到一个Android的MediaController从布局XML的出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆