코드네임 :

📱 모프 과제 헛둘헛둘 📱 본문

백엔드/Android_JAVA

📱 모프 과제 헛둘헛둘 📱

비엔 Vien 2024. 11. 21. 18:05

나 왜 시작화면 2초 안뜨지 이거 코드 맞는거 같은데 ㅠㅠ??

View view = findViewById(R.id.main);
view.postDelayed(new Runnable() {
    @Override
    public void run() {
        //IntroActivity에서 MainActivity로 이동 후 현재 액티비티 종료하기
        //Intent?

        Intent intent = new Intent(IntroActivity.this, MainActivity.class); //Intro에서 Main으로 전환
        startActivity(intent); //MainActivity로 이동하기(intent를 전달하여 새로운 액티비티 시작)
        finish(); //현재액티비티(IntroActivity)종료
    }
}, 2000); //2000ms 2초동안 스플래시 화면 보여줌

 

 

정말고마워 어

 

 

굿굿 아주 잘된다


음 이거 드로어블로 안되는디

 

어 알겟어

 

 

네비게이션 구현 완.. 

package com.example.hw2023111402;

import android.os.Bundle;
import android.view.MenuItem;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentTransaction;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;

public class MainActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        BookFragment bookFragment = new BookFragment();
        CenterFragment centerFragment = new CenterFragment();
        HomeFragment homeFragment = new HomeFragment();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.rootlayout, bookFragment);
        fragmentTransaction.commit();

        BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
        bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {

                FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
                if (item.getItemId() == R.id.tabBook){
                    fragmentTransaction.replace(R.id.rootlayout, bookFragment).commit();
                    return true;
                } else if (item.getItemId() == R.id.tabCenter){
                    fragmentTransaction.replace(R.id.rootlayout, centerFragment).commit();
                    return true;
                } else if (item.getItemId() == R.id.tabHome){
                    fragmentTransaction.replace(R.id.rootlayout, homeFragment).commit();
                    return true;
                } else return false;
            }
        });

    }
}