-1

Below is the fragment from where i want to start a new activity

public class Admin extends Fragment {
    public Admin() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_admin, container, false);
    }
}
erb
  • 14,503
  • 5
  • 30
  • 38

1 Answers1

1

You have to add your activity starting process within the OnClick function of your button

button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent myIntent = new Intent(FirstActivity.this, SecondActivity.class);
            FirstActivity.this.startActivity(myIntent);
        }
}

Don't forget to add your second activity in your manifest too

<activity android:label="@string/second_activity" android:name="SecondActivity"/>

Refer to this question

Community
  • 1
  • 1
Jackyto
  • 1,569
  • 3
  • 15
  • 33