开发者

How to show video thumbnail with text in a ListView?

What is the best way to show video thumbnail with text in a ListView row?

I want to display videos from the folder on the sdcard.

Also it is needed to lock the folder for the app.

开发者_JAVA百科

Each video will have a description and duration.


Try creating a custom adapter class by extending the BaseAdapter class and overrride the

getView(int position, View convertView, ViewGroup parent) method.

Example:

public class CustomListItemAdapter extends BaseAdapter {    
    private Context context;

    /**
     * overrides the  getView function
     */
    public View getView(int position, View arg1, ViewGroup arg2) {

        LayoutInflater inflater = LayoutInflater.from(context);
        RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.movielist_item, null,false);


        Movie ListItem = moviesList.get(position);

        /** sets the image bitmap for the imageview */
        if (moviewBmp != null)  {
            ImageView movieImg = (ImageView) root.findViewById(R.id.imgMovie);
            movieImg.setImageBitmap(movieImg );
        }

        /** sets the movie name text */
        TextView movieName = (TextView)root.findViewById(R.id.movieListItemName);
        movieName.setText(movieListItem.getMovieName());

        return root;
    }
}

and set it as a ListAdapter in your main activity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜