“未解决的类'Floating_label'”,“无法解析标志”错误

时间:2019-10-25 18:15:07

标签: android-studio kotlin

activity_floating_label.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Floating_label"
    android:orientation="vertical" >

   <com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:errorEnabled="true" >

   <EditText
    android:id="@+id/text_User_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="User Name"
    android:inputType="text_input_Username"
    android:textSize="26dp" />

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        app:passwordToggleEnabled="true" >

        <EditText
            android:id="@+id/text_input_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Password"
            android:inputType="text_input_password"
            android:textSize="26dp" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Confirm"
            android:id="@+id/con_btn"
            android:textAllCaps="false" />

   </com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
    </LinearLayout>

对应的kt文件的代码:

package com.example.assignment3muyaozhang0882423
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.R
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import android.widget.Toast.makeText

class setion2 : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_setion2)
        con_btn.isAllCaps = false

        val usernamestring = text_input_username.text
        val passwordstring = text_input_password.text
        con_btn.isAllCaps = false
        con_btn.setOnClickListener {
            if (this.usernamestring.isNotEmpty() && this.passwordstring.isNotEmpty()) {
                val message =
                    "User Name: " + usernamestring + "\n" + "Password: " + this.passwordstring
                Toast.makeText(this, message, LENGTH_LONG).show()
            } else {
                Toast.makeText(this, "Please enter valid input", LENGTH_LONG).show()
            }
        }
    }
}

其中有三个错误,一个是未解决类'Floating_label'的错误,两个是“无法解析标志”的错误。当我运行程序时,它说“ Android资源链接失败”。您能帮我识别一下吗?非常感谢!!

0 个答案:

没有答案