I'm starting out in android development, and I've been tackling the basics of a user interface, currently that means dragging and dropping images. I finally found a good example of that here for a textview, but I'd like to use it to drag around an imageview. What changes would I be required to make in order to have that occur? Thanks in advance for being patient with such a basic question.
Asked
Active
Viewed 473 times
1 Answers
0
These two lines:
_view = new TextView(this);
_view.setText("TextView!!!!!!!!");
Just have to be changed to:
_view = new ImageView(this);
_view.setImageResource(R.drawable...); // Whatever image
And TextView _view;
has to be changed to ImageView _view;
.
A note, though... you should probably learn a bit about what the code does, and how to manipulate View
objects in Android Java before getting too heavily into code like this.

Cat
- 66,919
- 24
- 133
- 141
-
Much appreciated, and I'll do that. If you have the time, I'd love your input on what resources I should look into to help me understand it better beyond random googling of lines. – user1398478 Oct 21 '12 at 04:01
-
[This blog](http://android-er.blogspot.ca/2011/06/add-view-using-java-code.html) has a decent rundown of `View`s through Java. A search for ["android adding views with java"](https://www.google.com/search?hl=en&q=android+adding+views+with+java) yields some pretty good results. – Cat Oct 21 '12 at 04:05
-
Thanks a lot, one last question, is this method less than ideal for dragging multiple views on the one activity, or can it be done? – user1398478 Oct 25 '12 at 07:47
-
@user1398478 It shouldn't matter how you create the objects (via Java or XML), as long as you handle them properly. – Cat Oct 25 '12 at 15:23