android-ラーニング-タッチポイントの座標を取得


コード:
package com.example.administrator.sockettx;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class view_tree extends Activity {
    EditText edit_call;
    Button b_call;
    Button touch;
    float y =0;
    float x =0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view);
        edit_call = (EditText)findViewById(R.id.edit_call);
        b_call  = (Button)findViewById(R.id.call);
        touch = (Button)findViewById(R.id.touch);
        touch.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                x=event.getRawX();
                y=event.getRawY();
                touch.setText(x+","+y);
                if(x>0&&x<150&&y>250&&y<400){
                    Intent intent_home = new Intent(view_tree.this,MainActivity.class);
                    startActivity(intent_home);
                }
                return false;
            }
        });
        b_call.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String number=edit_call.getText().toString();
                if (number.equals("")){
                    Toast.makeText(view_tree.this,"       ",Toast.LENGTH_SHORT).show();
                }
                else
                {
                    Intent intent=new Intent();
                    intent.setAction(Intent.ACTION_CALL);
                    intent.setData(Uri.parse("tel:"+number));
                    startActivity(intent);
                }

            }
        });

    }

}