I am new to Android, i tried to use an ontouchevent()
to detect screen touch, i worked on one of the sample page but when i copy pasted the same code in another page it doesn't seem to be working.
I think it has something to do with the View
.
Can someone please help me on this.
Code
public class HelpDesk extends Activity{
@Override
public void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
ImageButton home = (ImageButton)findViewById(R.id.home);
ImageButton exit = (ImageButton)findViewById(R.id.exit);
final Intent homeIntent = new Intent(this,MobNavSys4VisuallyImpaired.class);
home.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
startActivity(homeIntent);
}
});
exit.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
startActivity(homeIntent);
}
});
}
public boolean onTouchEvent(MotionEvent event)
{
System.out.print("touch");
Toast.makeText(this, "hiiiiii", Toast.LENGTH_SHORT).show ();
return true;
}}
`
check it
change return true;
to return super.onTouchEvent(event);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.