neko and Fragments

56 views
Skip to first unread message

Răzvan Rotaru

unread,
Sep 1, 2015, 3:01:58 PM9/1/15
to clojure-android
Hi,

I am trying to add a MapFragment to an Activity. According to the documentation, this should look like this:

 mMapFragment = MapFragment.newInstance();
 
FragmentTransaction fragmentTransaction =
         getFragmentManager
().beginTransaction();
 fragmentTransaction
.add(R.id.my_container, mMapFragment);
 fragmentTransaction
.commit();

Is there some support in neko for working with Fragments? What would be the recommended way to do this in neko?

Razvan

Alexander Yakushev

unread,
Sep 2, 2015, 6:47:10 AM9/2/15
to clojure-android
Hello Răzvan,

There is currently no wrapper for fragments in Neko, except for neko.activity/simple-fragment — which is very basic. So you have to use interop to define and set fragments. But I'm very open to suggestions of how the Fragment API can be implemented in Neko. When you write your fragment code with interop, and then see some common patterns that can be abstracted — tell me and we'll work something out.

Best regards,
Alex

Răzvan Rotaru

unread,
Sep 2, 2015, 11:30:20 AM9/2/15
to clojure-android
I confess I'm also having troubles using interop (because of my poor android knowlegde). How can I get "R.id.my_container" from (*a) ?

Alexander Yakushev

unread,
Sep 2, 2015, 12:09:45 PM9/2/15
to clojure-android
You can create a :frame-layourt in your activity's UI, and give it some keyworded ID, like {:id ::my-container}. Then you can use interop, and in place of ID use (neko.-utils/int-id ::my-container). That should work.
Reply all
Reply to author
Forward
0 new messages