2017-06-29 1 views
0

Ich habe ein XML-Layout in einer zweiten Aktivität, die eine von zwei LinearLayouts basierend darauf zeigt, ob ein Benutzer angemeldet ist oder nicht, und die TextView Ich habe nie den Text angezeigt in der App, aber es macht es richtig, wenn ich auf die "Design" -Panel im Layout-EditorTextView zeigt auf Design-Vorschau, aber nicht in tatsächlichen Android-App

Die TextView ist da (wenn ich eine Hintergrundfarbe, zeigt es diese Farbe), aber der Text selbst wird nie gerendert .

einen Knopf auf MainActivity Ergebnisse Durch Klicken auf die LoginActivity in starten, die die onCreate hat (es ist Kotlin):

override fun onCreate(savedInstanceState: Bundle?) { 
     super.onCreate(savedInstanceState) 
     setContentView(R.layout.login_layout) 

und Layout:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:visibility="gone" 
     android:id="@+id/loggedOut" 
     android:padding="24dp"> 

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

      <EditText 
       android:id="@+id/passName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:ems="10" 
       android:focusable="true" 
       android:hint="Username" 
       android:inputType="textCapCharacters" /> 
     </android.support.design.widget.TextInputLayout> 

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

      <EditText 
       android:id="@+id/passPin" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:ems="10" 
       android:focusable="true" 
       android:hint="PIN" 
       android:inputType="numberPassword" /> 
     </android.support.design.widget.TextInputLayout> 

     <Button 
      android:id="@+id/passSubmit" 
      style="@style/Widget.AppCompat.Button.Colored" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Login" /> 
    </LinearLayout> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:id="@+id/loggedIn" 
     android:visibility="visible" 
     android:padding="24dp"> 


     <TextView 
      android:id="@+id/loggedInMessage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="You're currently logged in" 
      android:textAlignment="center" 
      android:textAppearance="@android:style/TextAppearance.Material.Headline" /> 

     <Button 
      android:id="@+id/passLogout" 
      style="@style/Widget.AppCompat.Button.Colored" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Logout" /> 
    </LinearLayout> 

</FrameLayout> 

Dies ist, was Android Studio zeigt (diese Fehler sind TextInputLayout Bugs, wo es sagt, dass es nicht finden kann, das Passwort Passwort-Symbol und so) What Android Studio shows me

Und das ist, was mein Gerät
What I get on my device

Bearbeiten zeigt: Ich habe alles in der Layout-Datei entfernt mit Ausnahme der TextView und Eltern LinearLayout und es zeigt immer noch nicht.

+0

ich den 'TextInputLayout' die Frage, ob das war zu sehen, zu entfernen versuchte, keinen Wert hat. Während die Designwarnungen gelöscht wurden, bleibt das Problem bestehen – Parker

+0

Was passiert, wenn Sie diese Zeile entfernen? Android: textAppearance = "@ android: style/TextAppearance.Material.Headline" /> '? –

+0

Nein, gerade versucht, und tatsächlich sogar reduziert XML zu nur 'LinearLayout' und' TextView' – Parker

Antwort

1

Das Problem gefunden. Switching android:text="You're currently logged in" zu android:text="You\'re currently logged in" repariert es. Also, ich denke, Android erfordert es, einfache Anführungszeichen zu umgehen, wenn Sie den Text in XML setzen?

Gefunden das Layout Inspektor-Tool, das mText zeigte

+0

Ja, tut es. Aber Lint hätte sich darüber beschweren sollen. –

+0

Hmm, habe diesen Fehler nie gesehen, nur Ausgabe gab es beschwerte, dass ich die Zeichenfolge fest codierte. Ich bin auf Android Studio 3 Canary 4, also vielleicht ist es nur Buggy? – Parker

+1

Oder vielleicht Lint ist falsch konfiguriert - Sie können ihre Beschwerden nach Ihrem Willen stummschalten. –

Verwandte Themen