レイアウト, ToolBar修正

This commit is contained in:
r-ca 2024-01-23 03:22:01 +09:00
parent b11b78fa7f
commit 87099ae693
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 25 additions and 6 deletions

View File

@ -17,6 +17,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout; import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -71,7 +72,6 @@ public class HomeTopFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home_top, container, false); View view = inflater.inflate(R.layout.fragment_home_top, container, false);
setHasOptionsMenu(true);
return view; return view;
} }
@ -81,6 +81,8 @@ public class HomeTopFragment extends Fragment {
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
Toolbar toolbar = view.findViewById(R.id.home_toolbar);
toolbarSetup(toolbar, false, "ホーム");
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> { ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
Log.d("HomeTopFragment", "onViewCreated: " + documentId); Log.d("HomeTopFragment", "onViewCreated: " + documentId);
@ -99,10 +101,27 @@ public class HomeTopFragment extends Fragment {
}); });
} }
@Override /**
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { * ToolbarをInitする
inflater.inflate(R.menu.drawer_menu, menu); *
super.onCreateOptionsMenu(menu, inflater); * @param toolbar Toolbar
* @param showBackButton 戻るボタンを表示するか
* @param title タイトル
*/
private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) {
getActivity().runOnUiThread(() -> {
if (showBackButton) {
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
toolbar.setNavigationOnClickListener(v -> {
//this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join();
// Back
Navigation.findNavController(requireView()).popBackStack();
});
} else {
toolbar.setNavigationIcon(null);
}
toolbar.setTitle(title);
});
} }
} }

View File

@ -29,7 +29,7 @@
app:layout_scrollFlags="scroll|exitUntilCollapsed"> app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/home_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"