I am struggiling to implement a fragment UI with Ruboto. I had a perfectly working activity wich was creating its view in its onCreate method, and that is what I am trying to port to a fragment.
I end up with something like this:
In the activity onCreate() method I just build a placeholder for the fragment view;
#initial UI
setContentView(
frame_layout( :id => 100) do
text_view :text => "fragment place"
end
)
#fragment creation
ft = getFragmentManager().beginTransaction()
frag = MyFragment.new
ft.add( 100, frag )
ft.commit()
In the fragment onCreateView method, even returning a simple UI like this does not work
def onCreateView( inflater, container, savedInstanceState)
ruboto_import_widgets :TextView,
frag_view =
linear_layout(:orientation => :vertical) do
text_view :text => "fragment view"
end
return frag_view
end
But the fragment UI does not show, only the original UI is shown (no error in logcat either), what is wrong ?
Has someone successfully created a fragment UI with ruboto ?
I just added a new tutorial for using fragments with Ruboto here:
https://github.com/ruboto/ruboto/wiki/Tutorial:-fragments
The working example adds the fragments programmatically. We would like to show how to do it using XML layout as well, but it should answer your question. If you have any comments, we are tracking the issue here:
https://github.com/ruboto/ruboto/issues/492
Support for using "ruboto/widget" in fragments was just added to Ruboto master and will be released this month in Ruboto 0.16.0. We have added a new tutorial demonstrating the usage:
https://github.com/ruboto/ruboto/wiki/Tutorial:-dialogfragment
You can try the new feature now by building Ruboto from source.