播放视频成Android的列表视图 [英] playing a video into a listview in Android

查看:303
本文介绍了播放视频成Android的列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有点怪怪的,我想能演奏从列表视图的视频,但问题是videoView甚至没有放置在列表中。陌生的是,我设法过两次做到这一点没有任何问题,但现在还不能...而且我删除了previous脚本...
这里的脚本:

Something strange here, I am trying to play a video from a listview but the problem is the videoView is not even placed in the list. the stranger part is that I managed to do it twice before without any problem but now can't... And I deleted the previous scripts... here the script:

public class Dadapt extends BaseAdapter {
public int play = 0;

long timeWhenStopped = 0;

private String SOURCE = "source track";
// Declare Variables
Context context;
LayoutInflater inflater;
LayoutInflater flat;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
LoaderImage conteloader;
Audio_load audio_load;
ImageView im;
VideoView video;
AlertDialog.Builder builder;
HashMap<String, String> resultp = new HashMap<String, String>();
AQuery aq;

MediaController mc;

public Dadapt(Context context, ArrayList<HashMap<String, String>> arraylist) {
    this.context = context;
    data = arraylist;
    mc = new MediaController(context);
    video = new VideoView(context);
    imageLoader = new ImageLoader(context);
    aq = new AQuery(context);
    builder = new AlertDialog.Builder(context);
    // TODO Auto-generated constructor stub
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return data.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final TextView friend;
    final String type, vids;
    final LinearLayout lin;
    final ImageView avatar;
    final TextView name;
    final Button mess;
    final VideoView vid;
    inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View itemView = inflater.inflate(R.layout.event_list, parent, false);
    resultp = data.get(position);
    vid = (VideoView)itemView.findViewById(R.id.deo);
    type = resultp.get(Me.TYPE);
    vids ="http://xxxxxxx.com/" + resultp.get(Me.MEDIA);
    lin = (LinearLayout) itemView.findViewById(R.id.near);
    avatar = (ImageView) itemView.findViewById(R.id.event_pic);

    if (type.equalsIgnoreCase("video")) {
        mc.setMediaPlayer(vid);
        vid.setMediaController(mc);
        vid.setVideoPath(vids);
        vid.start();

    } else {
        imageLoader.DisplayImage3(
                "http://xxxxxxxx/" + resultp.get(Me.MEDIA), avatar);
    }

    friend = (TextView) itemView.findViewById(R.id.event_title);
    friend.setText(resultp.get(Me.NAME));
    name = (TextView) itemView.findViewById(R.id.event_descr);
    name.setText(resultp.get(Me.DESCRIPTION));

    return itemView;
}

}

我是什么做错了吗?最奇怪的部分是,我做了previously两次,也许一个小的错误,我在这里做...

What am I doing wrong? The strangest part is that I done it previously twice so maybe a small error I made here...

这就像videoview甚至不显示在所有

It is like the videoview doesn't even show at all

修改

这里的XML code

here the XML code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="@android:drawable/toast_frame"
android:orientation="vertical"
android:padding="5dp" >

<LinearLayout
    android:id="@+id/near"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical"
    android:padding="5dp"
    android:paddingTop="0dp" >

    <ImageView
        android:id="@+id/event_pic"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp" />

    <VideoView
        android:id="@+id/deo"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:id="@+id/event_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#777777"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/event_descr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:textAlignment="inherit" />

    <Button
        android:id="@+id/event_go"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/show_me"
        android:textColor="#777777" />

</LinearLayout>

在我logcat中看到:
    12-04 21:12:51.980:D / AbsListView(10157):unregisterIRListener()被调用

on the logcat I see: 12-04 21:12:51.980: D/AbsListView(10157): unregisterIRListener() is called

推荐答案

好了,挖了有关情况后,看起来好像是你不能把一个videoView一个ListView里面,所以我没有痘痘的把戏,我只是把一个gridview只一列是没有的伎俩

Well, after digging around, it appear that you just can not put a videoView inside a listView so I did a litle trick, I just put a gridView with just one column and that did the trick

这篇关于播放视频成Android的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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