Click here to Skip to main content
15,884,099 members

imageview motion event EnumCommands

Khaled Mohamed El Sawy asked:

Open original thread
I am building an application that controls a computer through an Android device till now I have finished the computer Java side and i have finished most of the android code that receives the image stream in ImageView .
So i made EnumCommands as following :
Java
public enum EnumCommands {
    PRESS_MOUSE(-1),
    RELEASE_MOUSE(-2),
    PRESS_KEY(-3),
    RELEASE_KEY(-4),
    MOVE_MOUSE(-5);

    private int abbrev;

    EnumCommands(int abbrev){
        this.abbrev = abbrev;
    }

    public int getAbbrev(){
        return abbrev;
    }
}

then in the main activity i tried to make the touch listeners to the ImageView
as MotionEvent.ACTION_DOWN , MotionEvent.ACTION_MOVE ,
Java
case MotionEvent.ACTION_MOVE:
				int x_cord = (int) event.getRawX();
				int y_cord = (int) event.getRawY();

				if (x_cord > windowwidth) {
					x_cord = windowwidth;
				}
				if (y_cord > windowheight) {
					y_cord = windowheight;
				}

				layoutParams.leftMargin = x_cord - 25;
				layoutParams.topMargin = y_cord - 75;

				IV.setLayoutParams(layoutParams);
				break;

So what i need is code for all the touch and motion events and the EnumCommands for my this project.
t
I really tried hard for searching the answer and failed
thanks in advance.
Tags: Mobile Apps (Android), Server

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900