android - The method onListItemClick(ListView, View, int, long) is undefined for the type Fragment -
i getting method onlistitemclick(listview, view, int, long) undefined type fragment
error:
fragmentc.java:
package com.example.fragment; import android.graphics.color; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmenttransaction; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.view.viewgroup.layoutparams; import android.widget.listview; import android.widget.textview; public class fragmentc extends fragment{ textview mtext; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { textview mtext = new textview(getactivity()); mtext.settext("fragment c added. \n click button go previous state"); mtext.setbackgroundcolor(color.magenta); mtext.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); return mtext; } public void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); <---error occurred here if(position == 2) { fragment newfrag = new fragmentc(); fragmenttransaction trans = getfragmentmanager().begintransaction(); trans.add(r.id.fragment_container, newfrag); trans.addtobackstack(null); trans.commit(); } else { } } }
anybody know how solve these.thanks in advance.
public class fragmentc extends fragment{
fragment not have method.
listfragment
has method. extend listfragment
instead of fragment
http://developer.android.com/reference/android/app/listfragment.html
but in fragment have textview
. why require onlistitemclick
when don't extend listfragment
?. don't see listview
either. have textview
, give no other information of need.
Comments
Post a Comment