저는 Android에 익숙하지 않아 액티비티로만 앱을 개발했습니다. 이제이를 변경하고 조각이있는 탐색 서랍을 만들었습니다.탐색 드로어에 조각을 소개하십시오.
문제는 활동을 조각으로 변경하는 방법을 모른다는 것입니다. 내가 봤어 무엇
:
<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="games.asee.videogames_asee_project.BlankFragment">
<ListView
android:id="@+id/listTOP"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/background_light" />
</FrameLayout>
: 모든
첫째, 나는 BlankFragment
을 만들고 나는 조각이 순간에 BlankFragment라고 내 활동에 적응이 레이아웃입니다
이 조각의 클래스 (난 단지 onCreateView의 코드를 수정)입니다 :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JuegosOperaciones crud = JuegosOperaciones.getInstance(getContext());
items = crud.getTOP();
adapter = new JuegoAdapter(getContext(), items);
ListView itemsListView = (ListView) getView().findViewById(R.id.listTOP);
itemsListView.setAdapter(adapter);
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank, container, false);
}
그러나 navigationDrawer에서 프래그먼트를 호출하는 방법을 모르겠다. getFragmentManager
을 호출하려고 시도했지만 앱이 아무 것도하지 않는다!
} else if (id == R.id.nav_manage) {
// getFragmentManager().beginTransaction().add(R.id.listTOP,new BlankFragment()).commit();
}
자세한 코드가 필요하면 알려주십시오.
다시 한 번 감사드립니다.
초보자는 https://guides.codepath.com/android/fragment-navigation-drawer를 사용해보십시오. – fida1989