gpt4 book ai didi

android - 在 Android 中将视频播放到 ListView 中

转载 作者:行者123 更新时间:2023-11-29 21:23:53 26 4
gpt4 key购买 nike

这里有些奇怪,我正在尝试从 ListView 播放视频,但问题是 videoView 甚至没有放在列表中。奇怪的是,我之前成功地做了两次,但现在不能了……而且我删除了以前的脚本……这里的脚本:

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;
}

我做错了什么?最奇怪的是我之前做过两次,所以我在这里犯了一个小错误......

就好像videoview根本不显示

编辑

这里是 XML 代码

<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() 被调用

最佳答案

好吧,在仔细研究之后,您似乎无法将 videoView 放入 listView 中,所以我做了一个小技巧,我只是放了一个只有一列的 gridView,这就成功了

关于android - 在 Android 中将视频播放到 ListView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20389200/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com