开发者

How to create popup media player on listview in android?

开发者 https://www.devze.com 2023-01-16 02:39 出处:网络
I have a songs list-view and I want to show pop-up media player when item in lis开发者_运维百科t-view clicked. A pop-up is a activity. But I don\'t know how to show pop-up activity on list-activity.Pl

I have a songs list-view and I want to show pop-up media player when item in lis开发者_运维百科t-view clicked. A pop-up is a activity. But I don't know how to show pop-up activity on list-activity.Please can anybody help me ?


One way is to use an ACTION_VIEW intent to open the video in Android's video player. (If you have other apps installed that can also play video the user will be prompted to choose one, and they can set a default to save being prompted every time.)

So for example, in your ListActivity subclass's onCreate method:

getListView().setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        try {
            Intent in = new Intent(Intent.ACTION_VIEW);
            in.setDataAndType(Uri.parse("http://example.org/video.mp4"), "video/*");
            startActivity(in);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消