1

在我的 android xml 布局中编写 EditText 时,我遇到了一个新错误。布局的代码是:

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="10dip" >

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Full Name"
                        android:textColor="#372c24" />

                    <EditText
                        android:id="@+id/reg_fullname"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="20dip"
                        android:layout_marginTop="5dip"
                        android:imeOptions="actionNext" />

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Email:"
                        android:textColor="#372c24" />

                    **<EditText
                        android:id="@+id/reg_email"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="20dip"
                        android:layout_marginTop="5dip"
                        android:imeOptions="actionNext" />**

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Password"
                        android:textColor="#372c24" />

                    **<EditText
                        android:id="@+id/reg_password"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dip"
                        android:imeOptions="actionDone" />**

                    <Button
                        android:id="@+id/saveBtn"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:imeOptions="actionSend"
                        android:text="LOGIN" />
                </LinearLayout>

错误跟踪是:

    Caused by: android.view.InflateException: Binary XML file line #72: Error inflating class android.widget.EditText
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.createView(LayoutInflater.java:596)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.app.Activity.setContentView(Activity.java:1777)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at com.bearing.inhouse.DashboardActivity.onCreate(DashboardActivity.java:38)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
04-23 09:11:56.109: E/AndroidRuntime(1692):     ... 11 more
04-23 09:11:56.109: E/AndroidRuntime(1692): Caused by: java.lang.reflect.InvocationTargetException
04-23 09:11:56.109: E/AndroidRuntime(1692):     at java.lang.reflect.Constructor.constructNative(Native Method)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.view.LayoutInflater.createView(LayoutInflater.java:576)
04-23 09:11:56.109: E/AndroidRuntime(1692):     ... 27 more
04-23 09:11:56.109: E/AndroidRuntime(1692): Caused by: java.lang.IllegalArgumentException: EditText cannot use the ellipsize mode TextUtils.TruncateAt.MARQUEE
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.widget.EditText.setEllipsize(EditText.java:112)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.widget.TextView.<init>(TextView.java:946)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.widget.EditText.<init>(EditText.java:58)
04-23 09:11:56.109: E/AndroidRuntime(1692):     at android.widget.EditText.<init>(EditText.java:54)
04-23 09:11:56.109: E/AndroidRuntime(1692):     ... 30 more

我以前使用过 EditText,但从未收到此错误。我从错误日志中不明白我应该做什么。你之前在代码中发现过这个错误吗?谢谢你。

4

2 回答 2

1

我在声明使用的地方找到了这个链接:

android:ellipsize="end"
android:singleLine="true"

这有效:

<EditText
       android:id="@+id/titleTxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:ellipsize="end"
        android:hint="title"
        android:inputType="text"
        android:singleLine="true"
        android:textColor="@android:color/black"
        android:textSize="@dimen/text_size_normal" />

希望它对你也一样。

于 2013-04-25T12:49:51.543 回答
1

设置此属性以编辑文本。Elipsize 正在使用禁用的文本编辑:

android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:singleLine="true"
android:editable="false"

或使用

setKeyListener(null);
于 2013-12-31T12:29:23.610 回答