I have Created 3 Activities and their class, i want to open them when button pressed, And buttons are in Fragment, i have successfully implemented this For A Single Button, and works. But I Want To do same thing for both button, How Can i make both button to open different activity in this class. i have included code..
Profilefragment.class
public class ProfileFragment extends Fragment {
View rootView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.profile, container, false);
Button newPage = (Button) v.findViewById(R.id.button2);
newPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), parseactivity.class);
startActivity(intent);
}
});
return v;
}
profilefragment.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
android:weightSum="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button1"
android:id="@+id/button1"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button2"
android:id="@+id/button2"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button3"
android:id="@+id/button3"
android:layout_gravity="center_horizontal" />
}