gpt4 book ai didi

java - NoClassDefFoundError :android. view.ViewAnimatorUtils

转载 作者:行者123 更新时间:2023-12-01 08:58:39 25 4
gpt4 key购买 nike

我有以下场景:按钮单击对话框应该以圆形显示效果打开。所以我已经实现了代码。单击按钮我遇到错误 NoClassDefFoundError:android.view.ViewAnimatorUtils 。下面是我的代码

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button)findViewById(R.id.button2);
linearLayout=(LinearLayout) findViewById(R.id.linearLay);
button.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onClick(View view) {
AlertDialog.Builder builder=new AlertDialog.Builder(getApplicationContext());
int x=view.getWidth()/2;
int y=view.getHeight()/2;
int finalRadius=Math.max(x,y)/2;
Animator anim= ViewAnimationUtils.createCircularReveal(linearLayout,x,y,0,finalRadius);
anim.start();
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

}
});
}
});
}

MainActivity.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.dhaval.assignment10a.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/textView" />

<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:layout_marginLeft="50sp"
android:layout_marginTop="50sp" />

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textView"
android:layout_marginTop="16dp"
android:id="@id/linearLay">

</LinearLayout>

</RelativeLayout>
<小时/>

日志

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.view.ViewAnimationUtils
at com.example.dhaval.assignment10a.MainActivity$1.onClick(MainActivity.java:34)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

最佳答案

ViewAnimationUtils是在API级别21中添加的,需要将minsdk设置为21

关于java - NoClassDefFoundError :android. view.ViewAnimatorUtils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41871459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com