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

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

選項卡式 Activity 中 android 片段中的 drawable 錯誤

選項卡式 Activity 中 android 片段中的 drawable 錯誤

躍然一笑 2023-02-23 17:25:34
我在 android studio 中的選項卡式活動片段中使用 Drawable 作為按鈕。但是它在返回視圖時會出錯并且應用程序崩潰。不使用 drawable 它工作正常。 我的按鈕片段 xml 代碼在此處輸入圖像描述。logcat 給出錯誤的 java 代碼是使用 inflater 在 java 片段中返回視圖,它在后面。import android.content.Context;import android.net.Uri;import android.os.Bundle;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;public class tab1 extends Fragment {    @Override    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {        // Inflate the layout for this fragment        return inflater.inflate(R.layout.fragment_tab1, container, false);    }}應用程序崩潰后,logcat 中的代碼也出現錯誤06-28 04:36:00.823 6880-6880/com.example.tutor1 E/AndroidRuntime:致命異常:主進程:com.example.tutor1,PID:6880 android.view.InflateException:二進制 XML 文件第 69 行:錯誤在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) 在 android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 在 android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 在 android .view.LayoutInflater.inflate(LayoutInflater.java:504) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:414) 在 com.example.tutor1.tab1.onCreateView(tab1.java:18) 在 android.support。 v4.app.Fragment.performCreateView(Fragment.java:2439)各個選項卡的布局文件在這里:
查看完整描述

4 回答

?
三國紛爭

TA貢獻1804條經驗 獲得超7個贊

Drawable 不支持帶數字的名稱。所以請將繪圖名稱重命名為 button_design_one



查看完整回答
反對 回復 2023-02-23
?
守著一只汪

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

最后帶有數字的可繪制資源的名稱沒有問題,它不會崩潰。請檢查您的背景文件是否為矢量或其格式。而且您的代碼沒有問題。



查看完整回答
反對 回復 2023-02-23
?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

檢查您的可繪制背景圖像。



查看完整回答
反對 回復 2023-02-23
?
慕虎7371278

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

我處理了另一個項目的可繪制文件..它沒有用。但是在從頭開始創建我自己的可繪制文件之后。它工作正常,現在一切順利。



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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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