Answers for "open fragment from activity android"

2

open fragment from activity kotlin

if (savedInstanceState == null) {
            val f = DnsTestFragment()
            val t: FragmentTransaction = supportFragmentManager.beginTransaction()
            t.replace(binding.findastestFramelayout.id, f).commit()
        }
Posted by: Guest on August-17-2021
1

how to open an activity from a fragment

Button btn1 = (Button) thisLayout
            .findViewById(R.id.btnDb1);

    btn1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(getActivity(), otherActivity.class);
            ((MainActivity) getActivity()).startActivity(intent);

        }
    });

    return thisLayout;
}
Posted by: Guest on May-27-2020

Code answers related to "open fragment from activity android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language