ecsoftware/directionboard — pull request #14 by karthiesr (2014-04-16 13:12:20+00:00)
Title: Merge pull request #5 from ecsoftware/sprint0

Design View

Source Code :

package com.ecsoft;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.Toast;

public class LaunchActivity extends Activity implements OnClickListener {

ImageView img;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launch);
initialize();

img.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {

// int action = event.getAction();
int x = (int) event.getX();
int y = (int) event.getY();
Log.d("x", x + "");
Log.d("y", y + "");
if ((x >= 150 && x <= 254) && (y >= 545 && y <= 565)) {
Toast.makeText(getApplicationContext(), "WOW...",
Toast.LENGTH_SHORT).show();
}

return true;
}
});

}

private void initialize() {
img = (ImageView) findViewById(R.id.img);
img.setOnClickListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.launch, menu);
return true;
}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.img:
int[] values = new int[2];
v.getLocationOnScreen(values);
Log.d("X & Y", values[0] + " " + values[1]);

break;
}
}

}