gpt4 book ai didi

android - 膨胀 xml 中的类集时出错

转载 作者:行者123 更新时间:2023-11-29 21:02:08 27 4
gpt4 key购买 nike

我正在尝试创建一个在屏幕上滑动的 textView,但它会产生错误,但我不知道为什么。这是我的 xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillAfter="true">

<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />

<TextView
android:id="@+id/scroll_message"
android:text="@string/scroll_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:minLines="1"
android:maxLines="10"
android:width="250dp"
android:textColor="@android:color/black"
android:textStyle="bold" />

</set>

还有我的 Activity 课:

package com.example.rsa.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ScrollView;


public class MyActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
//TextView txt = (TextView) findViewById(R.id.scroll_message);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.activity_my, menu);
return true;
}
}

给出的错误是:

            09-10 09:02:47.117  31292-31292/com.example.rsa.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.rsa.myapplication, PID: 31292
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rsa.myapplication/com.example.rsa.myapplication.MyActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class set
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.access$800(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5070)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class set
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:753)
at android.view.LayoutInflater.inflate(LayoutInflater.java:478)
at android.view.LayoutInflater.inflate(LayoutInflater.java:410)
at android.view.LayoutInflater.inflate(LayoutInflater.java:361)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:2122)
at com.example.ranjeev.myapplication.MyActivity.onCreate(MyActivity.java:23)
at android.app.Activity.performCreate(Activity.java:5720)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)

什么会导致这个错误?

最佳答案

在代码中使用动画集,像这样:

public void onResume(){
super.onResume();
textView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up));
}

关于android - 膨胀 xml 中的类集时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25766474/

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