android - showing a FragmmentDialog from calls that extends View class -
i have activity called mainpage
, extends sherlockfragmentactivity
. activity has tabs, each tab shows different fragment. 1 of fragments displays salerow
view custom view (class extends relativelayout
class). have saledialog
class extends dialogfragment
. trying show saledialog salerow
view class. tried use code:
public class salerow extends relativelayout { public salerow(context context) { super(context); ... this.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { fragmentmanager fm = getfragmentmanager(); //compilation error here getfragmentmanager method getfragmentmanager() undefined type new view.onclicklistener() saledialog testdialog = new saledialog(); testdialog.setretaininstance(true); testdialog.show(fm, "fragment_name"); } });
i have search solution couldn't find relevant.
thaks
try keeping reference context
object, cast , call getsupportfragmentmanager
on it:
public class salerow extends relativelayout { private context mcontext; public salerow(context context) { super(context); mcontext = context; this.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { try{ fragmentmanager fm = ((fragmentactivity) mcontext).getsupportfragmentmanager(); } catch (classcastexception e) { log.d(tag, "can't fragment manager frmom context"); } saledialog testdialog = new saledialog(); testdialog.setretaininstance(true); testdialog.show(fm, "fragment_name"); } }); } }
Comments
Post a Comment