当我在activity_main中单击Update Faculty(MaterialCardView)时。xml活动更新教员。xml应该显示,但我的应用程序崩溃并关闭,我试图在logcat中找到问题,它说“androidx.recyclerview.widget.recyclerview无法转换为android.widget.LinearLayout”我还是新手,所以很难找到问题。谁能帮帮我吗
以下是活动的主要内容。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"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView
android:id="@+id/addNotice"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="135dp"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/circle_green"
android:padding="15dp"
android:src="@drawable/ic_notice" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/lightGray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Upload Notice"
android:textColor="@color/textColor"
android:textStyle="bold" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/addGalleryImage"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/circle_purple"
android:padding="15dp"
android:src="@drawable/ic_gallery"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/lightGray"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Upload Image"
android:textColor="@color/textColor"
android:textStyle="bold"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView
android:id="@+id/addEbook"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/circle_pink"
android:padding="15dp"
android:src="@drawable/ic_upload"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/lightGray"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Upload Ebook"
android:textColor="@color/textColor"
android:textStyle="bold"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/faculty"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/circle_yellow"
android:padding="15dp"
android:src="@drawable/ic_group"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/lightGray"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Update Faculty"
android:textColor="@color/textColor"
android:textStyle="bold"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView
android:id="@+id/deleteNotice"
android:layout_width="130dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/cicle_red"
android:padding="15dp"
android:src="@drawable/ic_delete"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/lightGray"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Delete Notice"
android:textColor="@color/textColor"
android:textStyle="bold"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</LinearLayout>
这里是MainActivity.java:
package com.example.adminuniversityapp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.example.adminuniversityapp.facculty.UpdateFaculty;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
CardView uploadNptice, addGalleryImage, addEbook, faculty;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
uploadNptice = findViewById(R.id.addNotice);
addGalleryImage = findViewById(R.id.addGalleryImage);
addEbook = findViewById(R.id.addEbook);
faculty = findViewById(R.id.faculty);
uploadNptice.setOnClickListener(this);
addGalleryImage.setOnClickListener(this);
addEbook.setOnClickListener(this);
faculty.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent;
switch (v.getId()){
case R.id.addNotice:
intent = new Intent( MainActivity.this,UploadNotice.class);
startActivity(intent);
break;
case R.id.addGalleryImage:
intent = new Intent( MainActivity.this,UploadImage.class);
startActivity(intent);
break;
case R.id.addEbook:
intent = new Intent( MainActivity.this,UploadPdfActivity.class);
startActivity(intent);
break;
case R.id.faculty:
intent = new Intent( MainActivity.this, UpdateFaculty.class);
startActivity(intent);
break;
}
}
}
activity_update_faculty.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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=".facculty.UpdateFaculty">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
app:elevation="3dp"
app:fabSize="normal"/>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Computer Science"
android:textColor="@color/textColor"
android:textSize="22sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginVertical="8dp"
android:background="#c1c1c1"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/csDepartment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/csNoData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/no_data_found"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Mechanical Engineering"
android:textColor="@color/textColor"
android:textSize="22sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginVertical="8dp"
android:background="#c1c1c1"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/mechanicalDepartment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/mechNoData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/no_data_found"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Physics Department"
android:textColor="@color/textColor"
android:textSize="22sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginVertical="8dp"
android:background="#c1c1c1"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/physicsDepatment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/physicsNoData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/no_data_found"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Chemistry Department"
android:textColor="@color/textColor"
android:textSize="22sp"
android:textStyle="bold"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginVertical="8dp"
android:background="#c1c1c1"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chemistryDepatment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/chemistryNoData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/no_data_found"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
**更新aculty.java:**
package com.example.adminuniversityapp.facculty;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.adminuniversityapp.R; // i had to import this from the other package in order for R.layout works
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class UpdateFaculty extends AppCompatActivity {
FloatingActionButton fab;
private RecyclerView csDepartment, mechanicalDepartment, physicalDepartment, chemistryDepartment;
private LinearLayout csNoData, mechNoData, physicsNoData, chemistryNoData;
private List<TeacherData> list, list2, list3, list4;
private TeacherAdapter adapter;
private DatabaseReference reference, dbRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_faculty);
csDepartment = findViewById(R.id.csDepartment);
mechanicalDepartment = findViewById(R.id.mechanicalDepartment);
physicalDepartment = findViewById(R.id.physicsDepatment);
chemistryDepartment = findViewById(R.id.chemistryDepatment);
csNoData = findViewById(R.id.csDepartment);
mechNoData = findViewById(R.id.mechNoData);
physicsNoData = findViewById(R.id.physicsNoData);
chemistryNoData = findViewById(R.id.chemistryNoData);
reference = FirebaseDatabase.getInstance().getReference().child("teacher");
csDepartment();
mechanicalDepartment();
physicalDepartment();
chemistryDepartment();
fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(UpdateFaculty.this, addTeacher.class));
}
});
}
private void csDepartment() {
dbRef = reference.child("Computer Science");
dbRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list = new ArrayList<>();
if(!dataSnapshot.exists()){
csNoData.setVisibility(View.VISIBLE);
csDepartment.setVisibility(View.GONE);
} else {
csNoData.setVisibility(View.GONE);
csDepartment.setVisibility(View.VISIBLE);
for (DataSnapshot snapshot: dataSnapshot.getChildren()){
TeacherData data = snapshot.getValue(TeacherData.class);
list.add(data);
}
csDepartment.setHasFixedSize(true);
csDepartment.setLayoutManager(new LinearLayoutManager(UpdateFaculty.this));
adapter = new TeacherAdapter(list, UpdateFaculty.this);
csDepartment.setAdapter(adapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(UpdateFaculty.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
private void mechanicalDepartment() {
dbRef = reference.child("Mechanical");
dbRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list2 = new ArrayList<>();
if(!dataSnapshot.exists()){
mechNoData.setVisibility(View.VISIBLE);
mechanicalDepartment.setVisibility(View.GONE);
} else {
mechNoData.setVisibility(View.GONE);
mechanicalDepartment.setVisibility(View.VISIBLE);
for (DataSnapshot snapshot: dataSnapshot.getChildren()){
TeacherData data = snapshot.getValue(TeacherData.class);
list2.add(data);
}
mechanicalDepartment.setHasFixedSize(true);
mechanicalDepartment.setLayoutManager(new LinearLayoutManager(UpdateFaculty.this));
adapter = new TeacherAdapter(list2, UpdateFaculty.this);
mechanicalDepartment.setAdapter(adapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(UpdateFaculty.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
private void physicalDepartment() {
dbRef = reference.child("Physics");
dbRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list3 = new ArrayList<>();
if(!dataSnapshot.exists()){
physicsNoData.setVisibility(View.VISIBLE);
physicalDepartment.setVisibility(View.GONE);
} else {
physicsNoData.setVisibility(View.GONE);
physicalDepartment.setVisibility(View.VISIBLE);
for (DataSnapshot snapshot: dataSnapshot.getChildren()){
TeacherData data = snapshot.getValue(TeacherData.class);
list3.add(data);
}
physicalDepartment.setHasFixedSize(true);
physicalDepartment.setLayoutManager(new LinearLayoutManager(UpdateFaculty.this));
adapter = new TeacherAdapter(list3, UpdateFaculty.this);
physicalDepartment.setAdapter(adapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(UpdateFaculty.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
private void chemistryDepartment() {
dbRef = reference.child("Chemistry");
dbRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list4 = new ArrayList<>();
if(!dataSnapshot.exists()){
chemistryNoData.setVisibility(View.VISIBLE);
chemistryDepartment.setVisibility(View.GONE);
} else {
chemistryNoData.setVisibility(View.GONE);
chemistryDepartment.setVisibility(View.VISIBLE);
for (DataSnapshot snapshot: dataSnapshot.getChildren()){
TeacherData data = snapshot.getValue(TeacherData.class);
list4.add(data);
}
chemistryDepartment.setHasFixedSize(true);
chemistryDepartment.setLayoutManager(new LinearLayoutManager(UpdateFaculty.this));
adapter = new TeacherAdapter(list4, UpdateFaculty.this);
chemistryDepartment.setAdapter(adapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(UpdateFaculty.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
以下是我单击Update Faculty MaterialCardView后在logcat上显示的内容:
2022-03-22 14:09:03.319 24645-24645/com.example.adminuniversityapp I/Timeline: Timeline: Activity_launch_request time:36107995
2022-03-22 14:09:03.344 24645-24702/com.example.adminuniversityapp V/FA: Recording user engagement, ms: 49869
2022-03-22 14:09:03.367 24645-24702/com.example.adminuniversityapp V/FA: Connecting to remote service
2022-03-22 14:09:03.369 24645-24671/com.example.adminuniversityapp V/FA: onActivityCreated
2022-03-22 14:09:03.373 24645-24702/com.example.adminuniversityapp V/FA: Connection attempt already in progress
2022-03-22 14:09:03.373 24645-24702/com.example.adminuniversityapp V/FA: Activity paused, time: 61111997
2022-03-22 14:09:03.375 24645-24645/com.example.adminuniversityapp D/DecorView[]: getWindowModeFromSystem windowmode is 1
2022-03-22 14:09:03.409 24645-24645/com.example.adminuniversityapp E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-03-22 14:09:03.409 24645-24645/com.example.adminuniversityapp I/FloatingActionButton: Setting a custom background is not supported.
2022-03-22 14:09:03.411 24645-24645/com.example.adminuniversityapp E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-03-22 14:09:03.468 24645-24645/com.example.adminuniversityapp E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-03-22 14:09:03.509 24645-24645/com.example.adminuniversityapp D/AndroidRuntime: Shutting down VM
2022-03-22 14:09:03.513 24645-24645/com.example.adminuniversityapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.adminuniversityapp, PID: 24645
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.adminuniversityapp/com.example.adminuniversityapp.facculty.UpdateFaculty}: java.lang.ClassCastException: androidx.recyclerview.widget.RecyclerView cannot be cast to android.widget.LinearLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3580)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3752)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2191)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8049)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
Caused by: java.lang.ClassCastException: androidx.recyclerview.widget.RecyclerView cannot be cast to android.widget.LinearLayout
at com.example.adminuniversityapp.facculty.UpdateFaculty.onCreate(UpdateFaculty.java:46)
csNoData = findViewById(R.id.csDepartment);
这就是异常发生的地方。原因是id为csDepartment
的视图是RecyclerView
而不是LinearLayout
。因此,不能转换为
LinearLayout`。
要解决此问题,请将该行代码替换为:
csNoData = findViewById(R.id.csNoData);
我试图通过使用新的回收器视图列出数据 这是我的 MainActivity.java 主要活动。xml 我的文本视图。xml Logcat: 第78行:
我无法在listview模板上修复此问题:我的帖子标题中有错误,但我不会将imageview转换为textview。这是我的代码: java代码的错误在我的文件的第58行,我将TextView id分配给TextView mq: 下面是日志: 06-25 16:08:32.497:D/Debug(14642):Prendo Textview MQ 06-25 16:08:32.497:D/Andr
主要内容:弗洛伊德算法的实现思路,弗洛伊德算法的具体实现在一个加权图中,如果想找到各个顶点之间的最短路径,可以考虑使用弗洛伊德算法。 弗洛伊德算法既适用于无向加权图,也适用于有向加权图。使用弗洛伊德算法查找最短路径时,只允许环路的权值为负数,其它路径的权值必须为非负数,否则算法执行过程会出错。 弗洛伊德算法的实现思路 弗洛伊德算法是基于 动态规划算法实现的,接下来我们以在图 1 所示的有向加权图中查找各个顶点之间的最短路径为例,讲解弗洛伊德算法的实现思
我得到以下例外在Android当点击一个按钮把我从一个活动到另一个(我是新的Android开发,所以它可能不是最聪明的问题): JAVAClassCastException:android。小装置。RelativeLayout无法转换为android。小装置。编辑文本 我已经尝试过清理项目好几次了,我尝试过Android工具中的修复项目属性选项,我检查过我的xml是否有错误,但我似乎无法解决这个问
我正在构建一个类似亚马逊的应用程序。对loginactivity进行编码后,我无法从mainactivity访问它,因为它总是崩溃 这是我的loginactivity.java 这是我的后勤活动布局 然后我得到这个错误 E/AndroidRuntime:致命异常:主进程:com。极大的快餐,PID:12305爪哇。lang.RuntimeException:无法启动活动组件信息{com.infin
在发帖之前,我已经读过很多类似的问题,但都没有运气。 当我确定错误正在出现时,代码部分是: 与该部分相关的特定XML文件是: 出现此异常的原因是什么?我如何修复? 当我使用线性时,我不完全确定为什么异常与相对布局有关。 请注意,我是Android新手,所以这可能不是最聪明的问题!提前感谢您的帮助! 按要求activity_main.xml代码(据我所知,我自己没有创建也没有碰过这个文件):