How do I start a child activity from a fragment?

I am using the snippet feature instead of the Group Activity tab. like this.

public class TabGroup1Activity extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    if (container == null) {

        return null;
    }

    Intent intent = new Intent(getActivity(), HomeActivity.class);
    getActivity().startActivity(intent);

    return (RelativeLayout) inflater.inflate(R.layout.home, container,
            false);
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}
}

      

it does not start as a child (starting from full screen) but I don't know how to start as a child.

Please help me...

+3


source to share


1 answer


Actions are meant to cover the entire screen, while slices are meant to cover all, some, or none of the screens. You don't have to expand Fragment

for yours Activity

, do it instead.

public class TabGroup1Activity extends FragmentActivity {

      



You don't want to run Activity

inside FragmentActivity

, you need to create a new one Fragment

and add it to the layout container in the layout TabGroup1Activity

using getSupportFragmentManager()

or getFragmentManager()

with FragmentTransaction

.

See http://developer.android.com/training/basics/fragments/creating.html

0


source







All Articles