android中getTranslationY()方法的替代方法是什么?

时间:2013-07-06 12:03:05

标签: android android-listview android-animation android-3.0-honeycomb android-listfragment

以下错误会在预蜂窝版本中引发。错误登录我的应用程序,显示如下:

07-06 11:48:32.563: E/AndroidRuntime(433): java.lang.NoSuchMethodError: android.widget.TextView.getTranslationY
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.quickreturntopanimation.AnimationFragment$2.onScroll(AnimationFragment.java:135)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:675)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2956)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.widget.AbsListView.onTouchEvent(AbsListView.java:2065)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.widget.ListView.onTouchEvent(ListView.java:3315)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.View.dispatchTouchEvent(View.java:3766)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.os.Looper.loop(Looper.java:123)
07-06 11:48:32.563: E/AndroidRuntime(433):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-06 11:48:32.563: E/AndroidRuntime(433):  at java.lang.reflect.Method.invokeNative(Native Method)
07-06 11:48:32.563: E/AndroidRuntime(433):  at java.lang.reflect.Method.invoke(Method.java:521)
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-06 11:48:32.563: E/AndroidRuntime(433):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-06 11:48:32.563: E/AndroidRuntime(433):  at dalvik.system.NativeStart.main(Native Method)

此行显示错误:

if(mQView.getTranslationY() != 0) {

感谢任何帮助.........提前致谢

2 个答案:

答案 0 :(得分:0)

在Honeycomb之前该功能不存在,因此您无法调用它。你需要找到一种不用调用该函数的方法。

答案 1 :(得分:0)

您可能想要使用NineOldAndroid。根据其文件

  

NineOldAndroid库包含Android 3.0中引入的几乎所有新属性的兼容性实现,允许您执行适用于每个API级别的非常复杂的动画。

你可以在这里找到它 - > NineOldAndroid