i have method fetch videos device , display in listview
. show album name , title default image thumbnail repeats in rows of listview
. method is
try { madapter = new simplecursoradapter( this, // use template displays text view r.layout.media_select_row, null, // map database columns... new string[] { mediastore.video.media.album, mediastore.video.media.title, mediastore.video.media._id}, // widget ids in row layout... new int[] { r.id.row_album, r.id.row_title, r.id.row_icon,}, 0); setlistadapter(madapter); getlistview().setitemscanfocus(true); // normal click - open editor getlistview().setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { cursor c = madapter.getcursor(); int dataindex = c.getcolumnindexorthrow(mediastore.video.media.data); string filename = c.getstring(dataindex); videofilename = filename; string substr = videofilename.substring(videofilename.length() - 3); if(substr.equals("mp4")) { if(callpath == 1) { intent intent = new intent(dubvideolist.this, dubstudio.class); intent.putextra("videopath", videofilename); startactivity(intent); }else if(callpath == 2){ intent intent = new intent(dubvideolist.this, dubstudiobeta.class); intent.putextra("videopath", videofilename); startactivity(intent); } }else{ toast.maketext(dubvideolist.this,getstring(r.string.mp4_support),toast.length_long).show(); } } }); minternalcursor = null; mexternalcursor = null; getloadermanager().initloader(internal_cursor_id, null, this); getloadermanager().initloader(external_cursor_id, null, this); } catch (securityexception e) { // no permission retrieve video? log.e("securityerror", e.tostring()); // todo error 1 } catch (illegalargumentexception e) { // no permission retrieve video? log.e("illegalargument", e.tostring()); // todo error 2 } madapter.setviewbinder(new simplecursoradapter.viewbinder() { public boolean setviewvalue(view view, cursor cursor, int columnindex) { if (view.getid() == r.id.row_icon) { setsoundiconfromcursor((imageview) view, cursor); return true; } return false; } });
now need replace default image each cell video's thumbnail ? there way ? have given row's xml
reference. in advance.
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <imageview android:id="@+id/row_icon" android:gravity="center_vertical" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginleft="4dp" android:layout_margintop="4dp" android:src="@drawable/filmicon" android:layout_gravity="center" /> <linearlayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_margintop="8dip" android:layout_marginbottom="8dip" android:layout_width="0px" android:layout_weight="1" android:layout_marginleft="10dp" android:layout_marginright="4dip"> <textview android:id="@+id/row_title" android:textcolor="#ff000000" android:textsize="18sp" android:singleline="true" android:shadowcolor="#999999" android:shadowdx="1" android:shadowdy="1" android:shadowradius="1" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1"/> <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <textview android:id="@+id/row_album" android:textcolor="#ff1bbcff" android:textsize="12sp" android:singleline="true" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1"/> </linearlayout> </linearlayout> </linearlayout>
to thumbnail, can use code
bitmap thumb = thumbnailutils.createvideothumbnail(video_path, mediastore.images.thumbnails.mini_kind);
Comments
Post a Comment