亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

XML 文件無法引用類文件

XML 文件無法引用類文件

至尊寶的傳說 2023-02-16 15:35:11
大約一周前,android studio 幾乎破壞了我編寫的所有代碼,因為某些關鍵問題在網上找不到太多。我試圖找到一個解決方案的是 xml 文件,無論是 AndroidManifest.xml 文件還是活動文件都在類上出錯。我嘗試使用 alt+enter 并讓它通過創建一個與已經存在的文件同名的新文件來自動修復它,并且在不到一秒鐘的時間內,錯誤消失只會再次出錯。我已經重新安裝了 android studio,試圖查看我是否以某種方式損壞了文件。我寫的唯一代碼是 2 個按鈕。因此,除非我做錯了什么,否則我不確定類中的代碼是如何導致這種情況的。在“tools:context”字段下,它在文件上出錯,指出無法識別類文件(在 xml 文件中)。主要活動:import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }    public void Options_Button1(View view) {        Intent option = new Intent(MainActivity.this,Options.class);        startActivity(option);    }    public void Add_Button1(View view){        Intent add = new Intent(MainActivity.this,placeholder.class);        startActivity(add);    }}活動 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="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginStart="16dp"        android:layout_marginTop="16dp"        android:clickable="true"        android:focusable="true"        android:onClick="Options_Button1"        android:text="@string/options6"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent" />
查看完整描述

1 回答

?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

解決方案如上文評論所述,通過 file=>invalidates Caches/Restart 清除緩存文件。



查看完整回答
反對 回復 2023-02-16
  • 1 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號