mirror of
				https://github.com/lacerta-doc/Lacerta.git
				synced 2025-11-04 00:40:49 +00:00 
			
		
		
		
	仮データを出力できるように調整した。
This commit is contained in:
		
							parent
							
								
									e0af9381cb
								
							
						
					
					
						commit
						866b8270fe
					
				@ -0,0 +1,46 @@
 | 
			
		||||
package one.nem.lacerta.feature.library;
 | 
			
		||||
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
 | 
			
		||||
import androidx.annotation.NonNull;
 | 
			
		||||
import androidx.recyclerview.widget.RecyclerView;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
 | 
			
		||||
 | 
			
		||||
    private List<String> documentList;
 | 
			
		||||
 | 
			
		||||
    public DocumentAdapter(List<String> documentList) {
 | 
			
		||||
        this.documentList = documentList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @NonNull
 | 
			
		||||
    @Override
 | 
			
		||||
    public DocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
			
		||||
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_library_menu, parent, false);
 | 
			
		||||
        return new DocumentViewHolder(view);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
 | 
			
		||||
        holder.title.setText(documentList.get(position));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getItemCount() {
 | 
			
		||||
        return documentList.size();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    class DocumentViewHolder extends RecyclerView.ViewHolder {
 | 
			
		||||
        TextView title;
 | 
			
		||||
 | 
			
		||||
        DocumentViewHolder(View itemView) {
 | 
			
		||||
            super(itemView);
 | 
			
		||||
            title = itemView.findViewById(R.id.debug_menu_item_title);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -65,45 +65,6 @@ public class LibraryTopFragment extends Fragment {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.DocumentViewHolder> {
 | 
			
		||||
 | 
			
		||||
        private List<String> documentList;
 | 
			
		||||
 | 
			
		||||
        public DocumentAdapter(List<String> documentList) {
 | 
			
		||||
            this.documentList = documentList;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @NonNull
 | 
			
		||||
        @Override
 | 
			
		||||
        public DocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
			
		||||
            View view = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, parent, false);
 | 
			
		||||
            return new DocumentViewHolder(view);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onBindViewHolder(@NonNull DocumentViewHolder holder, int position) {
 | 
			
		||||
            holder.bind(documentList.get(position));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public int getItemCount() {
 | 
			
		||||
            return documentList.size();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        class DocumentViewHolder extends RecyclerView.ViewHolder {
 | 
			
		||||
            private final TextView textView;
 | 
			
		||||
 | 
			
		||||
            DocumentViewHolder(View itemView) {
 | 
			
		||||
                super(itemView);
 | 
			
		||||
                textView = itemView.findViewById(android.R.id.text1);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            void bind(String document) {
 | 
			
		||||
                textView.setText(document);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 | 
			
		||||
        // Inflate the layout for this fragment
 | 
			
		||||
@ -112,6 +73,9 @@ public class LibraryTopFragment extends Fragment {
 | 
			
		||||
        // Use view.findViewById instead of findViewById
 | 
			
		||||
        RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
 | 
			
		||||
 | 
			
		||||
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
 | 
			
		||||
        documentRecyclerView.setLayoutManager(layoutManager);
 | 
			
		||||
 | 
			
		||||
        List<String> documentList = new ArrayList<>();
 | 
			
		||||
        documentList.add("Document A");
 | 
			
		||||
        documentList.add("Document B");
 | 
			
		||||
@ -122,8 +86,6 @@ public class LibraryTopFragment extends Fragment {
 | 
			
		||||
        documentRecyclerView.setAdapter(adapter);
 | 
			
		||||
 | 
			
		||||
// Use a LinearLayoutManager to specify the layout
 | 
			
		||||
        LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext());
 | 
			
		||||
        documentRecyclerView.setLayoutManager(layoutManager);
 | 
			
		||||
        return view;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,23 +1,24 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
			
		||||
    xmlns:tools="http://schemas.android.com/tools"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="match_parent"
 | 
			
		||||
    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
			
		||||
    android:theme="@style/Theme.Lacerta"
 | 
			
		||||
    tools:context=".LibraryTopFragment">
 | 
			
		||||
 | 
			
		||||
    <com.google.android.material.appbar.MaterialToolbar
 | 
			
		||||
        android:id="@+id/tool_bar"
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:background="@color/colorPrimaryContainer"
 | 
			
		||||
        app:titleTextColor="@color/colorOnPrimaryContainer"
 | 
			
		||||
        app:title="Library"
 | 
			
		||||
        android:minHeight="?attr/actionBarSize"
 | 
			
		||||
        android:theme="?attr/actionBarTheme"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent"/>
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent"
 | 
			
		||||
        app:title="Library"
 | 
			
		||||
        app:titleTextColor="@color/colorOnPrimaryContainer" />
 | 
			
		||||
 | 
			
		||||
    <androidx.recyclerview.widget.RecyclerView
 | 
			
		||||
        android:id="@+id/document_list"
 | 
			
		||||
@ -26,6 +27,6 @@
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent" />
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
 | 
			
		||||
 | 
			
		||||
</FrameLayout>
 | 
			
		||||
</androidx.constraintlayout.widget.ConstraintLayout>
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
 | 
			
		||||
    android:padding="16dp">
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/debug_menu_item_title"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:textSize="16sp"
 | 
			
		||||
        android:layout_marginEnd="8dp"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/debug_menu_item_description"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:textSize="14sp"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
 | 
			
		||||
 | 
			
		||||
</androidx.constraintlayout.widget.ConstraintLayout>
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user