android - Fragment to activity intent not working -


So, I'm doing a project, and I have a piece called homepg_fragment.java and I try to link him I'm doing the image button to go to another activity called MensAllShoes but it keeps crashing, can someone help me? I'm new to Android programming, as you can see.

This is my homepg_fragment.java

  package com .op.slidingmenu.slidelist; Import com.nyp.integrateshoebox.MensAllShoes; @SuppressLint ("NewAP") enhances the HOMEPG_Fragment slice of the public class (ImageButton Women, Gentlemen; Crate on Public Zero (Bundle Saved Instantstate) {Super.New (Saved Instantstate); setContentView (R.layout.homepg_fragment); Women = (ImageButton) findViewById (R.id.ladies1); gentlemen = (ImageButton) findViewById (R.id.men1);} public void cookies (views) {intent cookie = new intent (getActivity (), MensAllShoes.class); StartActivity (cookie);} Private Zero setContentView (integer viewallFragment) {// TODO auto-created method stub} @Override abstract View public onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) {see rootView = inflater.inflate (R.layout.homepg_fragment, container, false); returning root view;} personal reference getApplicationContext () {// TODO auto generated method stub return null;} private Imejiwu Viduviaiaidi (Int Ladies 1) {// Tudo auto-generated by the method stub return null;}  

}

and XML

  & lt; imageView android: id = "@ + id / reception" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: layout_alignParentTop = "true" android: src = "@ drawable / Wardkst" / & gt; & Lt; ImageButton Android: id = "@ + id / ladies1" Android: layout_width = "320dp" Android: layout_height = "210dp" Android: layout_below = "@ + id / welcome" Android: layout_marginBottom = "18dp" Android: layout_marginLeft = "31dp "Android: src =" @Drawable / FemaleHome "/> & Lt; Android: layout_hearg = "212dp" Android: layout_below = "@ + id / ladies1" Android: layout_marginBottom = "18dp" Android: layout_marginLeft = "31dp" "Android: src =" @drawable / mainhome "android: onClick =" cookie "/> & Lt; / RelativeLayout & gt;  to setContentView  Why have you define your methods  

FindViewById and getApplicationContext ? Get rid of them - it's definitely something you should not do.

onCreate ...

  Remove the following line from the setContentView (R.layout.homepg_fragment);  

... and move the following lines to that line after onCreateView where you inflate your routeview ...

  Find Ladies = (Image Button) VVBIID (Raid. Lady 1); Gentlemen = (ImageButton) findViewById (R.id.men1);  

In addition, as a separate, piece should be self-contained and reusable and not directly activity Should start. Instead, you should create a 'callback' interface implemented by fragment hosting activity . You then used to call activity which was pressed on the button and to specify the activity to trigger other activity Call the interface method. .


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -