錯誤在Studio中的API 21中的TextInputLayout中呈現。然而,在API級別23.在實時工作的完善上都TextInputEditText錯誤
The following classes could not be instantiated:
- android.support.design.widget.TextInputEditText (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.TextInputLayout (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
Exception Details java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at com.android.internal.util.XmlUtils_Delegate.convertValueToInt(XmlUtils_Delegate.java:47) at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:88) at android.content.res.BridgeTypedArray.getInt(BridgeTypedArray.java:204) at android.widget.TextView.<init>(TextView.java:1051) at android.widget.EditText.<init>(EditText.java:65) at android.widget.EditText.<init>(EditText.java:61) at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:62) at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:58) at android.support.design.widget.TextInputEditText.<init>(TextInputEditText.java:39) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
工作完美,我只是走一個人的基本細節在此。爲此我使用了各種EditText ........................................... .................................................. .......................................
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/background_first">
<LinearLayout
android:id="@+id/update_details_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="@string/u_fields"
android:padding="10dp"
android:textColor="@color/navy_blue"
android:textAlignment="center"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/navy_blue"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:padding="10dp"
android:textColor="@color/black"
android:text="@string/u_fields_text1"
android:layout_marginTop="7dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:theme="@style/Widget.Design.TextInputLayout"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.EditText
android:id="@+id/update_first_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/first_name_hint"
android:inputType="textCapCharacters"
android:imeActionId="@+id/update_first_name_action"
android:imeOptions="actionNext"
android:maxLength="20"
android:maxLines="1"
android:singleLine="true" />
<requestFocus/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.EditText
android:id="@+id/update_last_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/last_name_hint"
android:imeActionId="@+id/update_last_name_action"
android:imeOptions="actionNext"
android:inputType="textCapCharacters"
android:maxLines="1"
android:maxLength="15"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button
android:id="@+id/update_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/done"
android:textColor="@color/black"
android:layout_margin="7dp"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
請把你的代碼放在這裏 –
請按照這個鏈接https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html –
爲什麼我在API Level 21中得到這個。java.lang.StringIndexOutOfBoundsException :字符串索引超出範圍:0.但是,當我在我的手機中運行API級別21中的應用程序時,我不會發現任何問題。 TextInputEditText是否也支持低於23.2.0的api? – RisingSun