Answers for "android fragment"

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
1

change fragment in android studio

// put the following code in onClickListner
// public void onClickListner(View view){
Navigation.findNavController(view).navigate(R.id.action_fromFragment_toFragment);
// action_fromFragment_toFragment is the id of transformatino, look in fragment map.
// }
Posted by: Guest on July-03-2020
-2

fragment manager in android

Intent intent = new Intent(v.getContext(), Addbill.class);
        v.getContext().startActivity(intent);
        getActivity().finish();
Posted by: Guest on May-11-2020

Code answers related to "android fragment"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language