Fehlermeldung Unresolved reference tvAusgabe in der MainActivity

A

Arti851

Neues Mitglied
0
Hallo zusammen,
ich studiere Informatik und beschäftige mich seit neuestem nebenher mit der App Entwicklung in Android.
Ich möchte nach dem Studium in diesem Bereich arbeiten.Ich beschäftige mich erst seit paar Wochen mit der Thematik.

Nun habe ich diese Fehlermeldung im Code und habe auch nichts im Internet gefunden.
Im Buch steht ebenfalls nichts.
Der Code ist in Kotlin geschrieben und xml.

Fehlermeldung: Unresolved reference tvAusgabe in der MainActivity

die MainActivity:

Java:
package com.example.texte                                   

import androidx.appcompat.app.AppCompatActivity             
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*       

class MainActivity : AppCompatActivity() {                 
    override fun onCreate(savedInstanceState: Bundle?) {   
        super.onCreate(savedInstanceState)                 
        setContentView(R.layout.activity_main)             

        buVerbinden.setOnClickListener {
            val textEins = "Hallo Welt"                     
            val textZwei = "Guten Morgen"
            var textDrei: String
            textDrei = "Guten Abend"



            val ausgabe = "Verbinden: \n" + textEins + "\n" + textZwei + "\n" + textDrei
            tvAusgabe.text = ausgabe
        }
    }
}

die activity_main.sml

Java:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/BuVerbinden"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="5dp"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/buVerbinden"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/verbinden" />

    <Button
        android:id="@+id/buFormatieren"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/formatieren" />

    <TextView
        android:id="@+id/tvAusgabeEins"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="@string/tvAusgabeEins"
        android:textColor="#000000"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/tvAusgabeZwei"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="@string/tvAusgabeZwei"
        android:textColor="#000000"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/tvAusgabeDrei"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="@string/tvAusgabeDrei"
        android:textColor="#000000"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/tvAusgabeVier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="@string/tvAusgabeVier"
        android:textColor="#000000"
        android:textSize="25sp" />



</LinearLayout>

die strings Ressourcen

Java:
<resources>
    <string name="app_name">Texte</string>
    <string name="verbinden">Verbinden</string>
    <string name="formatieren">formatieren</string>
    <string name="tvAusgabeEins">Verbinden:</string>
    <string name="tvAusgabeZwei">Hallo Welt</string>
    <string name="tvAusgabeDrei">Guten Morgen</string>
    <string name="tvAusgabeVier">Guten Abend</string>
</resources>

Danke für eure Hilfe

Viele Grüße
 
Hallo

Dieser import ist veraltet kotlinx.android.synthetic.main.activity_main
Es bedingt auch ein plugin in der Gradel Projekt Datei wenn du es weiter benutzen willst.

"apply plugin: 'Kotlin-Android-extension"

Neuer ist das Viewbinding was auch jetzt in Java unterstützt wird.

View Binding | Android Developers
I
 
Vielen Dank!
Ich werde es mir anschauen und gegebenfalls nochmal melden.
 

Ähnliche Themen

S
Antworten
0
Aufrufe
586
Sergio13
S
stele
Antworten
4
Aufrufe
1.155
stele
stele
M
Antworten
3
Aufrufe
139
moin
M
Zurück
Oben Unten