Can someone tell me how should am i going to create my listview which look similar here.
有人可以告诉我,我应该如何创建我的列表视图,看起来类似于此处。
Problem 1: The listview example i show in the link only caters to 2 file object as you can see in the link but in my own context i need a rather more "dynamic" video_list which increase/decrease with respect to time, but how am i going to fulfill the sort of look and feel in my codes which has icons, file name, and file size yet at the same time looking clean and simple on each file object??
问题1:我在链接中显示的列表视图示例仅适用于2个文件对象,因为您可以在链接中看到,但在我自己的上下文中,我需要一个更加“动态”的video_list,它相对于时间增加/减少,但是怎么样我将在我的代码中实现那种具有图标,文件名和文件大小的外观和感觉,同时在每个文件对象上看起来干净简单?
Problem 2: And why is my listview having error when the directory is empty despite having this to handle the "empty" in my xml
问题2:为什么我的listview在目录为空时有错误,尽管有这个来处理我的xml中的“空”
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No File Directory found on SD Card"/>
Can someone guide on this matter because i'm rather new in android/java... Thanks
有人可以指导这件事,因为我是android / java的新手...谢谢
This is what i tried out so far...
这是我到目前为止尝试过的...
public class ListViewActivity extends ListActivity {
private List<String> videoItems = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videolistview);
getVideoFiles(new File("/sdcard/Video_List").listFiles());
}
public void getVideoFiles(File[] videoList)
{
videoItems = new ArrayList<String>();
for (File file : videoList)
{
videoItems.add(file.getName());
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, videoItems));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
}
}
EDITED
1 个解决方案
#1
0
To add your list of videos, simply use the following line:
要添加视频列表,只需使用以下行:
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Videos));
#1
0
To add your list of videos, simply use the following line:
要添加视频列表,只需使用以下行:
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Videos));