开发者

How we can drag an image from one table to another in android

I am newbie to Andr开发者_如何学Gooid.

Can we move one imageview from a table layout to another layout? If so how it can be done?

I had created an XML based view. In that view I created two table layout. Inside one table I place an image. Then I need to drag that image from the first table to second.


You can try this (roughly):

  1. Create a custom view class for the table rows, use that as root in your table row XML.
  2. In that class, implement onTouchEvent(MotionEvent).
  3. If the the action is ACTION_DOWN, create a placeholder view (either with an icon or with a copy of the row view) that floats on top of your ListView.
  4. If the action is ACTION_MOVE, move the placeholder view to the coordinates of the event.
  5. If the action is ACTION_UP, check the coordinates of the event. If they still lie inside the original ListView or outside bounds, discard the floating view and do nothing. If they are inside the other ListView, remove the row's data from the original ListView and add it to the other one. Do this through the CursorAdapter, Cursor, ContentProvider or however you supply data to the ListView.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜