Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / FriendActivity.java
package com.example.nemophila;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;

public class FriendActivity extends AppCompatActivity {
    private FriendActivityAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_friend);

        // 初期化
        List<FriendDataModel> friendsDataset = new ArrayList<>();  // 1行分の情報を持つDataModelを格納するリスト
        RecyclerView rv = findViewById(R.id.friendsList);  // recyclerViewを取得
        adapter = new FriendActivityAdapter(friendsDataset);  // adapterを取得

        //一行ずつを縦に(LinearLayout)表示するLayoutManagerを宣言
        LinearLayoutManager llm = new LinearLayoutManager(this);

        // 詳細不明(おまじない)
        RecyclerView.ItemDecoration itemDecoration =
                new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        rv.addItemDecoration(itemDecoration);
        rv.setHasFixedSize(true);
        rv.setLayoutManager(llm);

        // マイページ画面に画面遷移する
        Button backButton = findViewById(R.id.backMyPage);
        backButton.setOnClickListener(v -> {
            Intent intent = new Intent(getApplication(), MyPageActivity.class);
            startActivity(intent);
        });
        
    }
}