天道酬勤,学无止境

android:list view with thumbnail

I need to create the list view of video's with it thumbnail images.The image name come from the database.I can give value to textview but when try to give value to image view it crash also in bitmap

        class CustomSimpleCusorAdapter extends SimpleCursorAdapter{
    private Context context;
    private int layout;
    //TextView title;
    public CustomSimpleCusorAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to) {

        super(context, layout, c, from, to);
        // TODO Auto-generated constructor stub
        this.layout=layout;
        this.context =context;

    }

public View newView(Context context, Cursor cursor, ViewGroup parent) {

     LayoutInflater inflater = LayoutInflater.from(context);
      View view = inflater.inflate(layout, parent, false);

     return view;
    }
@Override
public void bindView(View v, Context context, Cursor c) {

    Log.d("DATABAT",c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_TITLE)));
    Log.d("DATABAT",c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_IMAGE)));

    TextView section_text = (TextView) v.findViewById(R.id.title);
    section_text.setText(c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_TITLE)));
    ImageView thumb =(ImageView)findViewById(R.id.icon);
  //         
    String filename = "flag_1";
      int id = context.getResources().getIdentifier(filename, "drawable", context.getString(R.string.package_str));
  Log.d("ID",""+id);

  thumb.setBackgroundResource(R.drawable.menuicon);

}

} 

Thanks

评论

Try this where

 String urldisplay=img_value.toString();
 InputStream in = new java.net.URL(urldisplay).openStream();
 mIcon11 = BitmapFactory.decodeStream(new PatchInputStream(in));
 mIcon11=ImageHelper.getRoundedCornerBitmap(mIcon11,30);
 holder.icon.setImageBitmap(mIcon11);

Okay ... treading lightly here, but this sounds exactly like the problem my buddy had when trying to display the thumbnails for his videos app ...

Here's an Encode/Decode tutorial for base64

And just for reference; here's the link to his app in the market (300,000+ downloads): Video Player

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • 列表过滤器自定义适配器不给出结果(List Filter Custom Adapter dont give result)
    问题 我正在开发有列表和上方编辑文本的应用程序,当我在editText中键入内容时,我应该得到与键入的word匹配的结果。 以下是我的活动和适配器。 **活动* * public class ListFilterActivity extends ListActivity{ ListView list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_filter); list = getListView(); list.isTextFilterEnabled(); // final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, // android.R.layout.simple_list_item_1, android.R.id.text1, // getModel()); final CustomAdapter adapter = new CustomAdapter(ListFilterActivity.this, getModel()); setListAdapter(adapter)
  • 来自 Mediastore 的 Android 列表中的排序顺序(Sort order in Android list from Mediastore)
    问题 我需要一个按最新排序的 Android视频库。 使用下面的代码,排序是最旧的视频在最前面,最新的视频在最后。 所以我需要在获取新录制的视频之前滚动整个列表。 任何想法来解决这个问题? private void init_phone_video_grid() { System.gc(); String[] proj = { MediaStore.Video.Media._ID, MediaStore.Video.Media.DATA, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.SIZE }; videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null); count = videocursor.getCount(); videolist = (ListView) findViewById(R.id.PhoneVideoList); videolist.setAdapter(new VideoAdapter(getApplicationContext())); videolist.setOnItemClickListener(videogridlistener); }
  • Sort order in Android list from Mediastore
    I need a video gallery on Android sorted by the newest. With the code below, the sorting is with oldest videos on top and newest videos on last. So I need to scroll the entire list before getting the new recorded videos. Any ideas to solve this ? private void init_phone_video_grid() { System.gc(); String[] proj = { MediaStore.Video.Media._ID, MediaStore.Video.Media.DATA, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.SIZE }; videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null); count = videocursor.getCount(); videolist = (ListView)
  • how to get video thumbnail of youtube video in android list in android [duplicate]
    This question already has answers here: How to display thumbnail of YouTube Videos in Android (5 answers) Closed 4 years ago. I am developing an application where I want to show a list which contains urls of youtube video. I am succeeded in showing list but problem is I am unable to show video thumbnail. How to create youtube video thumbnail programatically. Thank You Edited:-- Hiren Dabhi give solution which I am using now & it solved problem Thank You
  • Storing images and thumbnails on s3 in django
    I'm trying to get my images thumbnailed and stored on s3 using django-storages, boto, and sorl-thumbnail. I have it working, but it's very slow, even with small images. I don't mind it being slow when I save the form and upload the images to s3, but I'd like it to display the image quickly after that. The answer to this SO question explains that the thumbnail won't be created until first access, but that you can use get_thumbnail() to create it beforehand. Django + S3 (boto) + Sorl Thumbnail: Suggestions for optimisation I'm doing that, and now it seems that all entries into the thumbnail
  • Android ListView使用AsyncTask更新图像缩略图会导致视图回收(Android ListView updating of Image Thumbnails using AsyncTask Causes View recycling)
    问题 我一直在尝试获取缩略图以与ListView中的图像文件的AsyncTask一起使用。 我一直遇到行回收的常见问题,因此在滚动时缩略图被分配给错误的行。 我尝试将标签添加到ImageView,然后在AsyncTask的onPostExecute()中确认标签,但是尝试失败。 有人请帮忙! 定制适配器如下: public class MySimpleAdapter extends SimpleAdapter { public MySimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) { super(context, data, resource, from, to); // TODO Auto-generated constructor stub } public View getView(int position, View convertView, ViewGroup parent) { final View v = super.getView(position, convertView, parent); thumbnail = (ImageView) v.findViewById(R.id.thumbnail)
  • 图像的缩略图视图(Thumbnail view of images)
    问题 我想在View控制器中将某些图像显示为缩略图,但是我不知道该怎么做。 如果可以的话,任何人都可以给我一些想法或示例代码。 回答1 您是要问如何从较大的图像创建缩略图,还是要如何构建能够很好地显示缩略图的视图控制器? 构建一个视图控制器: 您可以使用TTPhotoViewController项目(说明)中的TTPhotoViewController,其行为类似于iPhone的内置相机胶卷来查看图像。 您可以查看来自Apple的Scrolling示例代码,此问题中提到了有关将其用于缩略图的问题。 如果您想自己构建一个,则可以考虑使用moriarty库中的GridView,既可以将其用作UIScrollView的大型网格,也可以基于UITableView的更高效的逐行使用。 在UIScrollView中存在关于优化图像加载的先前问题。 从较大的图像创建缩略图: 缩小图像的最简单的代码方法是,将其简单地显示在UIImageView并将其帧设置为所需的较小尺寸-可以为您缩放。 如果要保存缩略图或关心内存使用情况,则可以创建硬缩放版本。 下面的示例代码来自此博客文章,可以作为类别方法添加到UIImage中: - (UIImage*) imageScaledToSize: (CGSize) newSize { UIGraphicsBeginImageContext(newSize);
  • Android ListView updating of Image Thumbnails using AsyncTask Causes View recycling
    I have been trying to get thumbnails to work with an AsyncTask for image files in a ListView. I have been having the common problem of Row Recycling, and thus on scrolling thumbnails are being assigned to wrong rows. I have tried adding tags to the ImageView and then confirming the tags in the onPostExecute() in the AsyncTask, but however have been unsuccessful in my attempts. Someone please help! The custom adapter is as follows : public class MySimpleAdapter extends SimpleAdapter { public MySimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[]
  • How to run my RecyclerView with CardView in fragment?
    I have this code and everytime I tried to run it ..the application is not running not error but not running can anyone please help me to determine what is the reason for getting this kind of problem. because I'm doing RecyclerView with CardView in fragment I have this problem almost a week :( this is my code: public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> { private Context mContext ; private List<Book> mData ; public RecyclerViewAdapter(Context mContext, List<Book> mData) { this.mContext = mContext; this.mData = mData; } public
  • Android图库(查看)视频(还有缩略图问题)(Android Gallery (view) video (also thumbnail issues))
    问题 当前,我们有一个图库视图,我们需要在该视图中添加图像/视频的缩略图。 如果我们已经具有图像/视频的content:// URI,我们如何获取已经生成的缩略图(本机Gallery应用程序显示的缩略图)? (我们使用的是Android 1.6,视频。缩略图不存在) 回答1 在这里,你去..工作非常好.....! http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html 回答2 如果我理解正确,则您有由内容提供者提供并可以作为URI访问的图像和视频。 您要为此类图像和视频创建缩略图。 我不知道该如何处理视频文件,但这就是我将如何处理图像文件的方法。 使用ContentResolver的openInputStream方法将图像作为InputStream打开。 http://developer.android.com/reference/android/content/ContentResolver.html#openInputStream%28android.net.Uri%29 使用此方法使用上述InputStream创建一个BitmapDrawable http://developer.android.com/reference/android/graphics/drawable
  • Android:扫描目录并显示图片(缩略图)(图片不存储在mediastore中)(Android: Scanning a directory and displaying pictures (thumbnails) (pictures are not stored in the mediastore))
    问题 我最近使用我使用媒体查询和媒体存储设计的自定义图库对显示图片进行了一些测试......效果很好,但我真的需要做一些自定义的事情。 我不希望图片被扫描或在媒体商店中可用,因此我希望我的应用程序扫描目录并创建缩略图并显示这些缩略图。 我发现很难找到任何高质量的例子来做到这一点。 任何人都可以帮忙举一个小例子。 这是我想要做的。 图片存储在sdcard的目录中。 使用我的自定义图库,它会扫描此目录,但“不”使用媒体存储我需要显示目录的内容,但作为缩略图,我认为我需要先创建这个缩略图? 单击缩略图应该会显示我的自定义图库中的全屏图像。 我想我只需要一点帮助就可以从目录中获取图片,因为没有存储 int eh mediastore 所以我不能使用查询。 我担心的另一件事是我需要为这些图像中的每一个创建缩略图(即时??),因为显示图像但我怀疑缩小尺寸会影响性能。 任何人都可以伸出援助之手吗? 提前致谢 回答1 前段时间我也做了同样的事情。 您必须将图像所在的文件夹名称传递给setBaseFolder 。 此方法依次调用refresh() ,它 - 使用FilenameFilter (代码未包含但很容易实现)从该文件夹中获取所有名为orig_....jpg图像并将其保存在mFileList 。 然后我们调用notifyDataSetChanged() ,它依次为每个单元格触发getView(
  • 如何创建视频网址表单服务器的缩略图(How to create thumbnail of video url form server)
    问题 如何创建URL视频表单服务器的图像/缩略图 我尝试不起作用(不显示缩略图) String String url = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4"; Bitmap thumb = ThumbnailUtils.createVideoThumbnail(url,MediaStore.Images.Thumbnails.MINI_KIND); Glide.with(context).load(thumb).asBitmap() /*.override(convertDpToPx(100), convertDpToPx(100))*/ .placeholder(R.drawable.camera) .override(200, 200) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new BitmapImageViewTarget(img_view) { protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources()
  • on click RecyclerView go to another activity with data in android
    i am using RecyclerVeiw to display some images and on click its should start New Activity showing id, name of the RecyclerView. I implemented the code but its now working, its not clickable. below is my adapter import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import java.util.ArrayList; import zesteve.com.myapplication.Catagory; import
  • 如何使用 sorl-thumbnail? (django)(How do I use sorl-thumbnail? (django))
    问题 我一直在查看 sorl-thumbnail 的文档,但我仍然无法弄清楚如何: 1. 将图像上传到 sorl-thumbnail。 2. 有选择地显示来自 sorl-thumbnail 的图像。 (例如,从视图中从 sorl-thumbnail 加载特定图像并显示它,具有自定义大小等) 你能给出一些关于如何在 django 视图中使用这个库的具体例子吗? 提前致谢 : ) 回答1 如果您想要更大的灵活性,您可以直接在视图中生成缩略图。 以下内容直接来自 sorl-thumbnail 文档: from sorl.thumbnail import get_thumbnail im = get_thumbnail(my_file, '100x100', crop='center', quality=99) im那么与您从thumbnail模板标签中得到的相同。 因此,您可以将该变量添加到模板上下文中,或者只是其中的一部分。 例如,如果您只想要 URL: my_context = { 'image_url': im.url, } 回答2 您可以使用缩略图模板标签使用 sorl.thumbnail。 下面是一个例子: {% load thumbnail %} {% thumbnail recipe.image "430x250" as thumb %} <img src="{{
  • Using ASP.NET Server Controls in MVC?
    On my current project I need to add a functionality that allows the user to view a thumbnail of their uploaded PDF. I've found a handy component that achieves this (the basic version is free, but it's enough for my current needs). Anyways, the control is pretty outdated (2010), therefore there doesn't seem to be MVC support. On the demos they depict usage of the control as such: The View's Markup: <form method="post" runat="server" enctype="multipart/form-data"> <asp:Panel ID="thumbnailsPanel" runat="server" /> </form> The thumbnail control is instantiated via code, the byte array which
  • Listing thumbnails per bucket
    I have 2 classes. First is meant for searching for all folders, I mean Bucket list name. Seconds class makes thumbnails. But I need to have thumbnails per bucket. So when I push on my folder it should shows me all photos in it (thumbnails). Can somebody help me with it? First class: public class ThumbnailAdapter extends BaseAdapter { // Context required for performing queries private final Context mContext; // Cursor for thumbnails private final Cursor cursor; private final int imgId; private final int imgData; private final int count; public ThumbnailAdapter(Context c) { this.mContext = c; //
  • 列出每个存储桶的缩略图(Listing thumbnails per bucket)
    问题 我有2节课。 首先是搜索所有文件夹,我的意思是桶列表名称。 秒类制作缩略图。 但我需要每个桶都有缩略图。 因此,当我按下文件夹时,它应该会显示其中的所有照片(缩略图)。 有人可以帮我吗? 第一课: public class ThumbnailAdapter extends BaseAdapter { // Context required for performing queries private final Context mContext; // Cursor for thumbnails private final Cursor cursor; private final int imgId; private final int imgData; private final int count; public ThumbnailAdapter(Context c) { this.mContext = c; // Get list of all images, sorted by last taken first final String[] projection = { MediaStore.Images.Media.BUCKET_ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME }; String BUCKET
  • Android Horizontal scrolling image gallery(Android Horizontal scrolling image gallery)
    问题 我想创建带有水平图像库(具有一行和多列)的应用程序。 首先,我尝试使用gridview,但是它只能用作垂直滚动。 我可以为此使用ListView或GridView吗? 回答1 在Horizo​​ntalScrollView中创建LinearLayout,然后动态创建一个imageView并将该imageview添加到linearLayout中。 示例代码: <HorizontalScrollView android:id="@+id/horizontal_scroll" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/linear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > </LinearLayout> </HorizontalScrollView> 在onCreate()方法中,从xml文件中获取linearLayout的ID,然后将动态创建的ImageView添加到linearlayout中: LinearLayout layout =
  • android substuting the click with a timer
    I found this example and i have a small question: How can I remove the on click to a timer or a delay where it displays the first image and waits a couple of seconds then moves to the next image? http://mobile.dzone.com/news/displaying-images-sd-card?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+javalobby%2Ffrontpage+%28Javalobby+%2F+Java+Zone%29 Thank you. package blog.android.sdcard; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider
  • 获取* .mov视频IOS的缩略图(Getting a thumbnail of a *.mov video IOS)
    问题 我想获取用iPhone / iPAD拍摄的视频(* .mov)的缩略图。 我正在尝试为此使用AVFoundation库,并得到以下错误: couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo=0x15d90a30 {NSLocalizedDescription=Cannot Open, NSLocalizedFailureReason=This media format is not supported.} 代码: NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDir=[paths objectAtIndex:0]; NSString *videoPath=[documentDir stringByAppendingPathComponent:[NSString stringWithFormat:@"videos/%@.mov",videoName]]; AVURLAsset *asset=[[AVURLAsset alloc]