• 11
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

MotionEventCompat functions are deprecated

I am trying to add an onTouchEvent to a View, but I then see the deprecation support on this link: https://developer.android.com/sdk/support_api_diff/26.0.0-alpha1/changes/android.support.v4.view.MotionEventCompat.html.

enter image description here

It says, they are all deprecated. So what code should be used to replace the MotionEventCompat functions?

You can instead use the MotionEvent object directly to achieve the same.

Please see the example & comparison as below:

public boolean onTouch(MotionEvent motionEvent) {
    // previously you would do this
    final int action = MotionEventCompat.getActionMasked();
    // now you would do this
    final int action = motionEvent.getActionMasked();
}

I think you are confused, as some of the Android documentation has yet to update their sample code, so some of their sample code is still using the deprecated methods.

For more info, please read here.

Hope this helps.

  • 52
Reply Report