在我的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,我从来没有遇到过这个错误。我不明白错误日志我应该做什么。你之前在代码中发现了这个错误吗? 谢谢。
答案 0 :(得分:1)
我发现this link表示要使用:
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" />
希望它能为你做同样的事。
答案 1 :(得分:1)
设置此属性以编辑文本。 Elipsize正在使用禁用的文本编辑:
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:singleLine="true"
android:editable="false"
或使用
setKeyListener(null);