gpt4 book ai didi

android - 如何用新 View 滑动 ListView 会像android中的删除按钮一样出现?

转载 作者:行者123 更新时间:2023-11-30 03:12:48 25 4
gpt4 key购买 nike

我已经有了一个带有 simpleCursorAdapter 的 ListView ,并显示来自 SD 卡的所有视频的缩略图..

现在我想进一步扩展我的 ListView ,我想以编程方式添加带有代码的滑动 ListView ,而不使用任何已经给出的 SwipeLibrary,我想使用滑动创建我自己的一组代码

我想创建类似这些的东西 http://www.youtube.com/watch?v=E0352OH488M

我想在不使用其他程序员库的情况下创建自己的代码集..

这是我的代码

public class FRAGThisWeek extends ListFragment {

private static final String KEY_VIDEO_PATH = "AAA-1";
private static final String KEY_VIDEO_TITLE = "AAA-2";
private static final String KEY_VIDEO_ARTIST = "AAA-3";
private static final String KEY_VIDEO_DURATION = "AAA-4";
private static final String KEY_VIDEO_ID = "AAA-5";

/* SOURCE URI FROM SDCARD */

private static final Uri sourceUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
private static final String[] projection = { MediaStore.Video.Media._ID,
MediaStore.Video.Media.DATA, MediaStore.Video.Media.TITLE,
MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.ARTIST,
MediaStore.Video.Media.DURATION };
private static final String orderBy = MediaStore.Video.Media.DATE_ADDED;

/* THE DESIRED COLUMNS TO BE BOUND */
private static final String[] from = { MediaStore.Video.Media.TITLE,
MediaStore.Video.Media.ARTIST, MediaStore.Video.Media.DURATION };

/* THE XML DEFINED VIEWS WHICH THE DATA WILL BE BOUND TO */
private static final int[] to = { R.id.list_Title, R.id.list_Artist,
R.id.list_Duration };

private static Cursor videoCursor;
private static int videoPathColumnIndex;
private static int videoTitleColumnIndex;
private static int videoArtistColumnIndex;
private static int videoDurationColumnIndex;
private static int videoIdColumnIndex;

private static String videoPath;
private static String videoTitle;
private static String videoArtist;
private static int videoDuration;
private static int videoId;

/* TO LUNCH PLAY.CLASS AND PUT MEDIA INFO INTO */
private static Intent vIntent;

/* MY CUSTOM ADAPTER */
private static MyCustomSimpleCursorAdapter adapter;

/* MY LISTVIEW */
ListView lv;

/* CUSTOM TYPE INFLATION IF NEED TO ADD MORE VIEW IN LISTVIEW XML LAYOUT */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.frag_this_week, container, false);
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

// CREATE CURSOR THAT WILL HOLD ALL VALUE
videoCursor = getActivity().getContentResolver().query(sourceUri,
projection, null, null, orderBy);

// CREATE THE ADAPTER USING THE CURSOR POINTING TO THE
// DESIRED DATA AS WELL AS THE LAYOUT INFORMATION
adapter = new MyCustomSimpleCursorAdapter(getActivity(),
R.layout.list_row_items, videoCursor, from, to);

setListAdapter(adapter);

// GET THE INSTANCE OF LISTVIEW for the swipeview purpose
lv = getListView();
}

@Override
/* ListView Listener */
public void onListItemClick(ListView l, View v, int position, long id) {
Log.d("clicked", "clicked");
}

}

最佳答案

您为什么不看看这些库是如何制作的?

你基本上需要:

  • 每行一个 onTouchListener 来检测滑动手势
  • 一个对象动画师来移动你的观点。
  • 用于显示您的 View 的自定义适配器。

关于android - 如何用新 View 滑动 ListView 会像android中的删除按钮一样出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20654500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com