当前位置: 首页 > 知识库问答 >
问题:

inflating类Ja.BurhanRashid52.PhotoEditor.PhotoEditorView时出错

蔡楚
2023-03-14

目前,我正在开发一个使用PhotoEditor库的android应用程序。我遵循了入门设置视图部分的说明。但是,不知怎么的,我无法膨胀包含PhotoEditorView的UI XML。下面是我的代码:

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

        <ja.burhanrashid52.photoeditor.PhotoEditorView
            android:id="@+id/photoEditorView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </ja.burhanrashid52.photoeditor.PhotoEditorView>

</RelativeLayout>

片段:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    try {
        final View view = inflater.inflate(R.layout.app_fragment_edit_picture, container, false);
    }
    catch (Exception e) {
        LogHelper.LogError("TEST");
    }

    return null;
}

有人有线索吗?

按照要求,下面是完整的堆栈跟踪:

共有1个答案

益智明
2023-03-14

更新

包含Main、fragment xmls和类的完整代码。

MainActivity XML

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

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/fragmentContainer"/>

</LinearLayout>
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;


public class PhotoEditorActivity extends AppCompatActivity {
FragmentManager fragManager;
FragmentTransaction fragTransaction;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photo_editor);

    fragManager=getFragmentManager();
    fragManager.findFragmentById(R.id.fragmentContainer);
    fragTransaction=fragManager.beginTransaction();
    fragTransaction.replace(R.id.fragmentContainer, new PhotoEditorFragment());
    fragTransaction.commit();

}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">

<ja.burhanrashid52.photoeditor.PhotoEditorView
    android:id="@+id/photoEditorView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</ja.burhanrashid52.photoeditor.PhotoEditorView>

</RelativeLayout>
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class PhotoEditorFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle 
savedInstanceState) {
    View itemView=inflater.inflate(R.layout.photo_editor_fragment,container,false);
    try
    {
        return itemView;}
    catch (Exception e){
        return null;
    }

}
}
dependencies {
    implementation 'ja.burhanrashid52:photoeditor:0.4.0'
}
 类似资料: