2016-09-09 2 views
0

Der Versuch, Android-Entwicklung zu lernen. Ich verwende Android Studio 2.1.3 und habe versucht, eine Login-Funktion zu erstellen. Beim Erstellen des Projekts wurde die Login-Aktivitätsvorlage verwendet und alle anderen Optionen im Assistenten als Standard festgelegt. Als ich versuchte zu sehen, was genau es erstellt hat, wird dieser Fehler angezeigt.Die folgenden Klassen konnten nicht instanziiert werden: android.support.design.widget.TextInputLayout

Die folgenden Klassen können nicht instanziiert werden: android.support.design.widget.TextInputLayout

standardmäßig die Android-Version wurde zeigt Ziel als 24 ich es 15, aber immer noch die gleichen Fehler geändert. Wie löst man das?

enter image description here

Layout-xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
    android:orientation="vertical" 
    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.user.loginapp.Login"> 

    <!-- Login progress --> 
    <ProgressBar 
     android:id="@+id/login_progress" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="8dp" 
     android:visibility="gone" /> 

    <ScrollView 
     android:id="@+id/login_form" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:id="@+id/email_login_form" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <AutoCompleteTextView 
        android:id="@+id/email" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:hint="@string/prompt_email" 
        android:inputType="textEmailAddress" 
        android:maxLines="1" 
        android:singleLine="true" /> 

      </android.support.design.widget.TextInputLayout> 

      <android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <EditText 
        android:id="@+id/password" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:hint="@string/prompt_password" 
        android:imeActionId="@+id/login" 
        android:imeActionLabel="@string/action_sign_in_short" 
        android:imeOptions="actionUnspecified" 
        android:inputType="textPassword" 
        android:maxLines="1" 
        android:singleLine="true" /> 

      </android.support.design.widget.TextInputLayout> 

      <Button 
       android:id="@+id/email_sign_in_button" 
       style="?android:textAppearanceSmall" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="16dp" 
       android:text="@string/action_sign_in" 
       android:textStyle="bold" /> 

     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 
+0

Können Sie bitte das XML für die von Ihnen verwendete Layoutdatei angeben? –

+0

Versuchen Sie auch die Antworten auf http://StackOverflow.com/Questions/26575815/the-following-Classes-could-not-in-instantiated-android-support-v7-widget-too und sehen, ob einer von ihnen funktioniert Sie. –

+0

@ChadSchultz Ich habe die Frage jetzt mit Layout-XML aktualisiert. Auch ich habe versucht, Caches ungültig zu machen/Neustart es das Problem nicht gelöst hat. Auch ich habe versucht, die Android-Version von 24 bis 15 zu ändern es auch nicht das Problem gelöst – prasanth

Antwort

0

Sie entweder appcompat von compile 'com.android.support:appcompat-v7:xxx können zu Ihrem gradle hinzufügen oder Ihre minsdk in Ihrem gradle bis 21 oder höher wählen (Lolipop ist die erste Person Material Design unterstützen).

Read Documention here

, um mehr über die Aufrechterhaltung der Abwärtskompatibilität zu lernen.

Verwandte Themen