Tengo el siguiente Fragment:
public class FragmentFirst extends Fragment {
private OnFragmentInteractionListener mListener;
public FragmentFirst() {
// 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_fragment_second, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
public void ActivityMatematicas3 (View v){
final Animation animation = AnimationUtils.loadAnimation(FragmentFirst.this.getActivity(), R.anim.anim1);
v.startAnimation(animation);
Intent siguiente = new Intent(FragmentFirst.this.getActivity(),Matematicas3.class);
startActivity(siguiente);
}
}
El problema es que no me detecta ActivityMatematicas3
que está puesto en el metodo onClick
en su respectivo .xml, no lo encuentra, y no sé por qué, entonces cuando hago click no funciona.
Mi xml el cual está referenciado ActivityMatematicas3
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.teleco.espada.teleco.FragmentFirst"
android:background="#EAE8F6" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/custom_button3"
android:drawableLeft="@mipmap/integral"
android:drawablePadding="10dp"
android:gravity="center_horizontal|center"
android:onClick="ActivityMatematicas3"
android:text="MATEMÁTICAS I"
android:typeface="serif" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/phi"
android:drawablePadding="10dp"
android:text="FÍSICA I"
android:typeface="serif"
android:background="@drawable/custom_button3"
android:onClick="ActivityFisicaI" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout4"
android:layout_alignParentBottom="true"
android:layout_marginBottom="19dp" >
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/circuit"
android:drawablePadding="10dp"
android:text="T.CIRCUITOS"
android:typeface="serif"
android:background="@drawable/custom_button3"
android:onClick="ActivityTeoria"/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="18dp" >
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/laptop"
android:drawablePadding="10dp"
android:text="FCO"
android:typeface="serif"
android:onClick="ActivityFco"
android:background="@drawable/custom_button3"
android:layout_marginTop="44dp"
android:layout_below="@+id/linearLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="58dp"
android:layout_below="@+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/phi"
android:drawablePadding="10dp"
android:text="PROGRAMACIÓN"
android:typeface="serif"
android:onClick="ActivityProgramacion"
android:background="@drawable/custom_button3" />
</LinearLayout>
</RelativeLayout>