package com.example.screenlistener;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.Menu;

public class MainActivity extends Activity {
TextView tv;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
setContentView(ll);

tv = new TextView(this);
tv.setText("看什麼看!!沒看過美女。");

ll.addView(tv);
}

public boolean onTouchEvent(MotionEvent e)
{
if(e.getAction() == MotionEvent.ACTION_DOWN)
{
tv.setText("別亂摸!!小心我告你!!");
}
else if(e.getAction() == MotionEvent.ACTION_UP)
{
tv.setText("看什麼看!!沒看過美女。");
}
return true;
}

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

}

arrow
arrow
    文章標籤
    android screen touch listener
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()