내가 안드로이드에서 응용 프로그램을하고 있어요 내가 몇 조각을 설정하기 위해 노력하고있어하지만 응용 프로그램을 실행할 때마다이 두 가지 오류와 충돌 :안드로이드 조각 오류 팽창 클래스 단편
MainActivity: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class fragment
[email protected] must implement OnFragmentInteractionListener
인터넷 검색 많은 사람들이 XML 파일을 android :: name 클래스에서 변경했다고 생각했습니다. 나는 그것을했고 아직도 나에게 일어난다. 내 조각의 XML
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
Fragment fragment = new Fragment();
if (id == R.id.nav_camera) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.search_fragment, fragment);
ft.commit();
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
:
<FrameLayout 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=".SearchFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
그리고 나는 activity_main에 구현 :
<fragment android:id="@+id/search_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.onelio.app.SearchFragment"/>
어떻게 할 수
나는 조각으로 이동이 코드를 사용 고쳐? 감사합니다.