【Android API】java.util.List<E>

java.util.List<E>

属于公共接口,因此List<String> list = new List<String>();是无法实例化的。

已知间接子类:

Public Methods
abstract boolean add(E object)
Adds the specified object at the end of this List.
abstract void add(int location, E object)
Inserts the specified object into this List at the specified location.
abstract boolean addAll(Collection<? extends E> collection)
Adds the objects in the specified collection to the end of this List.
abstract boolean addAll(int location, Collection<? extends E> collection)
Inserts the objects in the specified collection at the specified location in this List.
abstract void clear()
Removes all elements from this List, leaving it empty.
abstract boolean contains(Object object)
Tests whether this List contains the specified object.
abstract boolean containsAll(Collection<?> collection)
Tests whether this List contains all objects contained in the specified collection.
abstract boolean equals(Object object)
Compares the given object with the List, and returns true if they represent the same object using a class specific comparison.
abstract E get(int location)
Returns the element at the specified location in this List.
abstract int hashCode()
Returns the hash code for this List.
abstract int indexOf(Object object)
Searches this List for the specified object and returns the index of the first occurrence.
abstract boolean isEmpty()
Returns whether this List contains no elements.
abstract Iterator<E> iterator()
Returns an iterator on the elements of this List.
abstract int lastIndexOf(Object object)
Searches this List for the specified object and returns the index of the last occurrence.
abstract ListIterator<E> listIterator(int location)
Returns a list iterator on the elements of this List.
abstract ListIterator<E> listIterator()
Returns a List iterator on the elements of this List.
abstract E remove(int location)
Removes the object at the specified location from this List.
abstract boolean remove(Object object)
Removes the first occurrence of the specified object from this List.
abstract boolean removeAll(Collection<?> collection)
Removes all occurrences in this List of each object in the specified collection.
abstract boolean retainAll(Collection<?> collection)
Removes all objects from this List that are not contained in the specified collection.
abstract E set(int location, E object)
Replaces the element at the specified location in this List with the specified object.
abstract int size()
Returns the number of elements in this List.
abstract List<E> subList(int start, int end)
Returns a List of the specified portion of this List from the given start index to the end index minus one.
abstract <T> T[] toArray(T[] array)
Returns an array containing all elements contained in this List.
abstract Object[] toArray()
Returns an array containing all elements contained in this List.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package com.music.zhangdaosen; import android.annotation.SuppressLint; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import android.util.Log; import android.widget.ArrayAdapter; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class SongHelper { public static List<Song>musicList = new ArrayList<>(); // static List<Song>musicList; public static List<Song> getLocalMusic(Context context){ Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; ContentResolver resolver = context.getContentResolver(); Cursor cursor = resolver.query(uri,null,null,null,null); if(cursor !=null){ Song song; while (cursor.moveToNext()){ song =new Song(); int index = cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME); song.name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME)); song.singer = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST)); song.path = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)); song.duration = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION)); Log.d("SongHelper--keyar","get"+song.name+" "+song.duration); musicList.add(song); SimpleDateFormat sdf = new SimpleDateFormat("mm:ss"); String time = sdf.format(new Date(song.duration)); } Log.d("SongHelper--keyar","get musicList"+ musicList.size()); } cursor.close(); return musicList; } public static String changeTime(int duration){ int min = duration/1000/60; int sec = duration/1000%60; if(sec<10){ return min+":0"+sec; } return min+":"+sec; } }
最新发布
06-03

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值