android - xamarin navigate from one fragment to another -


i trying navigate on fragment click button in original fragment. how ever got exception

image of exception

image of code original fragment

the problem passing layout in call of transaction.replace(), instead should pass id of viewgroup fragment inserted in layout.

so layout of activity containing fragments should this:

  <?xml version="1.0" encoding="utf-8"?>     <framelayout xmlns:android="http://schemas.android.com/apk/res/android"         <framelayout             android:id="@+id/content_frame"             android:layout_width="match_parent"             android:layout_height="fill_parent" />     </framelayout> 

and in fragmentstocksearch fragment, override oncreateview this:

public override view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     return inflater.inflate(resource.layout.your_layout, null, false); } 

and fragment transaction code:

var trans = new fragmentmanager.begintransaction(); trans.replace(resource.id.content_frame, new fragmentstocksearch(), "fragmentstocksearch"); trans.addtobackstack(null); trans.commit(); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -