我必须通过模板撰写屏幕。 有4个简单文本字段,4个文本输入字段和7个不同的按钮。此时我没有触及按钮,因为当我尝试构建我的项目时,Android Studio会发出下一个警告:
Missing classes:
The following classes could not be found:
- Description (Fix Build Path, Edit XML)
- Desease (Fix Build Path, Edit XML)
- InputDescription (Fix Build Path, Edit XML)
- InputDesease (Fix Build Path, Edit XML)
- InputLocation (Fix Build Path, Edit XML)
- InputName (Fix Build Path, Edit XML)
- Location (Fix Build Path, Edit XML)
- Name (Fix Build Path, Edit XML)
我在这里读到有关同一问题的文章, The following classes could not be found: android.support.v7.internal.app.WindowDecorActionBar 据我所知,在这里我必须宣布正确的班级。但我不明白我应该怎么做这个问题?为何A.S.说我的textViews是类吗? 2个xml文件如下所示: 首先是MainActivity,包含所有布局,在第二个xml中是actoinbar,我想在其中集中我的应用名称。
MainActivity XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="16dp"
android:orientation="vertical"
tools:context="com.example.boris_veriga.home_screen.MainActivity">
<Name
android:id="@+id/person_Name"
tools:text="@string/textView_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="100dp" />
<InputName
android:id="@+id/inputName"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:hint="@string/input_yourName"
android:inputType="textPersonName"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/person_Name" />
<Desease
android:id="@+id/person_Desease"
tools:text="@string/textView_desease"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="150dp" />
<InputDesease
android:id="@+id/inputDesease"
android:hint="@string/input_yourDesease"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/person_Desease"
android:inputType="textPersonName" />
<Location
android:id="@+id/person_Location"
tools:text="@string/textView_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="200dp" />
<InputLocation
android:id="@+id/inputLocation"
android:hint="@string/input_yourLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/person_Location"
android:inputType="textPersonName" />
<Description
android:id="@+id/person_Description"
tools:text="@string/textView_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="250dp" />
<InputDescription
android:id="@+id/inputDescription"
android:hint="@string/input_yourDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/person_Description"
android:inputType="textPersonName" />
</android.support.constraint.ConstraintLayout>
ActionBar - XML(我想在中心设置应用标题):
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ActionBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textStyle="bold"
android:textColor="#ffff"
android:textSize="24sp" />
</android.support.constraint.LinearLayout>
MainActivity - .java:
package com.example.boris_veriga.home_screen;
import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.actionbar);
setContentView(R.layout.activity_main);
}
}
P.S.:Sory为我的英语,我是Android的新手。 Thank'u !!!