본문 바로가기

카테고리 없음

안드로이드 프래드먼트 가져 오기

반응형

DeadLiftActivity.kt

package co.kr.sangji

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.content.Intent
import co.kr.sangji.fragments.DeadLift_description

class DeadLiftActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_dead_lift)

        // DeadLift_description 프래그먼트 추가
        if (savedInstanceState == null) {
            val fragment = DeadLift_description()
            val args = Bundle()
            args.putString("calledMenu", "MUSCLE_FUNCTION_RANGE") // 또는 적절한 메뉴 타입
            args.putString("type", "") // ROM 타입으로 설정
            fragment.arguments = args

            supportFragmentManager.beginTransaction()
                .add(R.id.fragment_container, fragment) // fragment_container는 레이아웃에 추가해야 함
                .commit()
        }
    }
}

activity_dead_lift.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".DeadLiftActivity">

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

 

반응형