3

我正在为 Android API 级别 19 及更高级别进行转换。我还向项目中添加了支持库,并使用了 getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS) 和 getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS) 标志。但是我仍然得到方法getSharedElementEnterTransition()的java.lang.NoSuchMethodError。谁能告诉我包含 API 级别 19 的转换方法的解决方案?

这是代码:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
            getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
        setContentView(R.layout.prescription);
         mPresLayout=(RelativeLayout)findViewById(R.id.pres_layout);
         mPres_text=(TextView)findViewById(R.id.pres_text);
         ViewCompat.setTransitionName(mPresLayout, PRESLAYOUT_NAME);
         ViewCompat.setTransitionName(mPres_text, PRESLAYOUT_TEXT);
         addTransitionListener();
         getWindow().setAllowEnterTransitionOverlap(false);
         getWindow().setAllowReturnTransitionOverlap(false);
         getWindow().setSharedElementExitTransition(null);
         getWindow().setSharedElementReenterTransition(reenterTransition());
    }
4

1 回答 1

3

It works fine with API 21 and above . API 19 do not recognize it.

于 2016-11-12T06:55:43.847 回答