Remove the android.R package and import the one which is having a package
name similar to your project package.
On Feb 4, 2016 4:53 AM, "Foo Fabulous" <[email protected]> wrote:

>
> <https://lh3.googleusercontent.com/-EHkJSOHEx4g/VrKLCovfHGI/AAAAAAAAAu4/8P45oyNi8xs/s1600/symbol%2Berrors_android.png>
> I tried to follow the tutorial as best I could @ Touch and Drag Image
> (youtube) <https://www.youtube.com/watch?v=DGuwi5X5vZw>
>
> The problem is at the lines:
>
> setContentView(R.layout.touchdrag);
>         iv=(ImageView)findViewById(R.id.iv);
>
>
> the error states that the symbols touchdrag and iv cannot be resolved.
>
>
> in the following TouchAndDrag.java file
>
>
> package org.foo.tabletop; /**
>  * Created by Foo on 2/3/2016.
>  */
> import android.app.Activity;
> import android.os.Bundle;
> import android.R;
> import android.view.MotionEvent;
> import android.view.View;
> import android.widget.ImageView;
>
>
> public class TouchAndDrag extends Activity implements View.OnTouchListener{
>     ImageView iv;
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.touchdrag);
>         iv=(ImageView)findViewById(R.id.iv);
>         iv.setOnTouchListener(this);
>     }
>     float x,y=0.0f;
>     boolean moving=false;
>     @Override
>     public boolean onTouch(View arg0, MotionEvent arg1) {
>         switch(arg1.getAction()){
>             case MotionEvent.ACTION_DOWN:
>                 moving=true;
>                 break;
>             case MotionEvent.ACTION_MOVE:
>                 if(moving){
>                     x=arg1.getRawX()-iv.getWidth()/2;
>                     y=arg1.getY()-iv.getWidth()*3/2;
>                     iv.setX(x);
>                     iv.setY(y);
>                 }
>                 break;
>             case MotionEvent.ACTION_UP:
>                 moving=false;
>                 break;
>         }
>         return true;
>     }
> }
>
>
> the touchdrag.xml file:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
>     android:layout_width="match_parent"
>     android:layout_height="match_parent">
>
>     <ImageView
>         android:layout_width="100dp"
>         android:layout_height="100dp"
>         android:id="@+id/iv"
>         android:src="@drawable/smiley" />
> </LinearLayout>
>
>
> Any help would be appreciated.
>
> Here is a screenshot that helps to show the structure of the app:
>
>
> <https://lh3.googleusercontent.com/-EHkJSOHEx4g/VrKLCovfHGI/AAAAAAAAAu4/8P45oyNi8xs/s1600/symbol%2Berrors_android.png>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/d9d591ac-9d08-4505-8fd5-1292ee378ea9%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/d9d591ac-9d08-4505-8fd5-1292ee378ea9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAMxwX4v46Eq3CBo73NR_bRK0xca74RRnqe8wT2ezb0G-ThStUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to