我创建了一个 ListView 列表, 它包含一个项目列表。 列表视图中的每个项目都有不同的图像。 我想要的是拖放列表视图中的每个图像, 意味着我可以移动列表视图中的项目位置 。
我想做的是:
我可以将列表中的每个图像从一个位置拖放到另一个位置。
单击列表视图中每个图像后,我要打开一个对话框。
如何做到这一点?请帮我举个合适的例子。
我创建了一个 ListView 列表, 它包含一个项目列表。 列表视图中的每个项目都有不同的图像。 我想要的是拖放列表视图中的每个图像, 意味着我可以移动列表视图中的项目位置 。
我想做的是:
我可以将列表中的每个图像从一个位置拖放到另一个位置。
单击列表视图中每个图像后,我要打开一个对话框。
如何做到这一点?请帮我举个合适的例子。
看看下面的“强势”DragNDropListView 强”中的代码。
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
final int x = (int) ev.getX();
final int y = (int) ev.getY();
if (action == MotionEvent.ACTION_DOWN && x < this.getWidth()/4) {
mDragMode = true;
}
.
不使用上面的代码, 仅在列表视图中允许拖放 。
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
final int x = (int) ev.getX();
final int y = (int) ev.getY();
int mWidth = this.getWidth() / 4; //calculating the quarter part
if (action == MotionEvent.ACTION_DOWN && x >= (mWidth * 2) && x < (mWidth * 3) ) {
mDragMode = true;
}
.
1) 无论 < 坚固> > < /坚固 > 值即将到来,你都需要检查它,就像要让拖放启用的地方一样。
2) To give a full privileged to user so that they can drag from any point of the lsit item use this
if (action == MotionEvent.ACTION_DOWN ) //don t check for x-position.
{
..
}
请看上面的代码
希望这能帮到你
@Anshuman 问得好
检查 < a href=" "http://www.google.co.in/url?sa=t&rct=j&q=rag%20and%20dlop%20example%20in%20android%20and%2020listview%20echarlow&source=web&cd=3&ved=0CFKQFAC&url=http://ericharlow.blogspot.com/2010/10/经验-android-drag-and-droid-and-dropp-list.html&ei=jsK8T5D3ELSrQftorC1Dw&usg=AFQjEqVMKCVxrP0TSWxid3xUamp;cad=rja" rel="nofolt" > this < a a非常简单的例子。
他用过
private ArrayList<String> mContent; //in DragNDropAdapter class
您需要使用 < 强 > 图像 < / 强 >, 请在 < 强 > 整个软件包 < / 强 > 上自定义
private ArrayList<Image> mContent; //in DragNDropAdapter class
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...