Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:25:43+00:00 2026-06-10T06:25:43+00:00

I am following this code to create a custom list view. It uses an

  • 0

I am following this code to create a custom list view.

It uses an XML file to parse objects and show them in Listview

I was wondering can I use the same example to show Videos Titles and Duration of a Youtube Playlist.

I have gone though Youtube API and GDATA but I can’t find out how to get raw xml link which I can use with above example code

Any help guys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:25:44+00:00Added an answer on June 10, 2026 at 6:25 am

    Heres a class I’ve used in one of my previous projects. This puts the first video as the “main” one, displays the time and title, and then adds all the rest of the videos to a layout.

    public class Videos extends Activity {
        ImageView mainThumb;
        TextView mainTitle;
        TextView mainTime;
        LinearLayout videos;
        ArrayList<String> links;
    
        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.videos);
    
            new ParseVideoDataTask().execute();
            mainThumb = (ImageView) findViewById(R.id.mainThumb);
            mainTitle = (TextView) findViewById(R.id.mainTitle);
            mainTime = (TextView) findViewById(R.id.mainTime);
            videos = (LinearLayout) findViewById(R.id.videos);
    
        }
    
        private class ParseVideoDataTask extends AsyncTask<String, String, String> {
            int count = 0;
    
            @Override
            protected String doInBackground(String... params) {
                URL jsonURL;
                URLConnection jc;
                links = new ArrayList<String>();
                try {
                    jsonURL = new URL("http://gdata.youtube.com/feeds/api/playlists/" +
                        YOUR PLAYLIST ID +  
                        "?v=2&alt=jsonc");
                     jc = jsonURL.openConnection(); 
                     InputStream is = jc.getInputStream(); 
                     String jsonTxt = IOUtils.toString(is); 
                     JSONObject jj = new JSONObject(jsonTxt); 
                     JSONObject jdata = jj.getJSONObject("data"); 
                     JSONArray aitems = jdata.getJSONArray("items"); 
                     for (int i=0;i<aitems.length();i++) {
                         JSONObject item = aitems.getJSONObject(i); 
                         JSONObject video = item.getJSONObject("video"); 
                         String title = video.getString("title");
                         JSONObject player = video.getJSONObject("player");
                         String link = player.getString("default");
                         String length = video.getString("duration");
                         JSONObject thumbnail = video.getJSONObject("thumbnail"); 
                         String thumbnailUrl = thumbnail.getString("hqDefault")
                         String[] deets = new String[4];
                         deets[0] = title;
                         deets[1] = thumbnailUrl;
                         deets[2] = length;
                         links.add(link);
                         publishProgress(deets);
                     }
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }       
                return null;
            }       
    
            @Override
            protected void onProgressUpdate(final String... deets) {
                count++;
                if (count == 1) {
                    MainActivity.setImageFromUrl(deets[1], mainThumb, Videos.this);
                    mainTitle.setText(deets[0]);
                    mainTime.setText(formatLength(deets[2]));
                    mainThumb.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(links.get(1)));
                            startActivity(i);
                        }
                    });
                } else {
                    LayoutInflater layoutInflater = (LayoutInflater)Videos.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View video = layoutInflater.inflate(R.layout.video, null);
                    ImageView thumb = (ImageView) video.findViewById(R.id.thumb);
                    TextView title = (TextView) video.findViewById(R.id.title);
                    TextView time = (TextView) video.findViewById(R.id.time);
                    MainActivity.setImageFromUrl(deets[1], thumb, Videos.this);
                    title.setText(deets[0]);
                    time.setText(formatLength(deets[2]));
                    video.setPadding(20, 20, 20, 20);
                    videos.addView(video);
                    video.setId(count-1);
                    video.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(links.get(v.getId())));
                            startActivity(i);
                        }
                    });
                }
            }
        }
    
        private CharSequence formatLength(String secs) {
            int secsIn = Integer.parseInt(secs);
            int hours = secsIn / 3600,
                    remainder = secsIn % 3600,
                    minutes = remainder / 60,
                    seconds = remainder % 60;
    
                    return ((minutes < 10 ? "0" : "") + minutes
                    + ":" + (seconds< 10 ? "0" : "") + seconds );
        }
    
        @Override
        public void onDestroy() {
            super.onDestroy();
            for (int i=0;i<videos.getChildCount();i++) {
                View v = videos.getChildAt(i);
                if (v instanceof ImageView) {
                    ImageView iv = (ImageView) v;           
                    ((BitmapDrawable)iv.getDrawable()).getBitmap().recycle();   
                }
            }
        }
    }
    

    video.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
            <ImageView
                android:id="@+id/thumb"
                android:layout_width="240dp"
                android:layout_height="180dp"
                android:layout_centerHorizontal="true"
                android:scaleType="fitStart" />
    
            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/thumb"
                android:layout_below="@+id/thumb"
                android:layout_toLeftOf="@+id/time"
                android:maxLines="1"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="@android:color/black" />
    
            <TextView
                android:id="@+id/time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignRight="@+id/thumb"
                android:layout_below="@+id/thumb"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="@android:color/black" />              
    
    
    </RelativeLayout>
    

    videos.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        android:orientation="vertical" >
        <RelativeLayout
            android:id="@+id/main"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >    
    
            <ImageView
                android:id="@+id/mainThumb"
                android:layout_width="240dp"
                android:layout_height="180dp"
                android:layout_centerHorizontal="true"
                android:scaleType="fitXY"/>
    
            <TextView
                android:id="@+id/mainTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/mainThumb"
                android:layout_below="@+id/mainThumb"
                android:layout_toLeftOf="@+id/mainTime"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="@android:color/black" />
    
            <TextView
                android:id="@+id/mainTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignRight="@+id/mainThumb"
                android:layout_below="@+id/mainThumb"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="@android:color/black" />              
        </RelativeLayout>
    
        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="none"
            android:layout_alignParentBottom="true" >
    
            <LinearLayout
                android:id="@+id/videos"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:gravity="center"
                android:orientation="horizontal" />
    
        </HorizontalScrollView>
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To use custom layout file in my app I'm using this following code, set
I'm following this tutorial to create a simple Hello World extension for Chrome: http://code.google.com/chrome/extensions/getstarted.html
Hi i am using the following code to generate a custom listview with checkbox.how
I was following this tutorial, as it's exactly what I need: http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/ Unfortunately, their
I'm trying to create a ListView with custom ArrayAdapter. Following the example from here.
I have done my custom ListView, the xml was following: <?xml version=1.0 encoding=utf-8?> <LinearLayout
I have this following test code: public static final String[] list = { apple,ball,cat,dog,egg,fan,girl,hat,igloo,jerk
I'm folowing this tutorial to create php/jquery based chat application. In short, this code
Following this code my button works perfectly: http://twitter.github.com/bootstrap/javascript.html#modals Fades and everything. I want to
I have this following code, here CssClass is of the String type. <asp:Panel ID=Panel1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.