I have a MainActivity class which extends SlidingMenu.
When the user clicks in the sliding menu on an item, I would like to reload the View(different layout and content) of MainActivity.
In most cases the new View would consiste of a ListView with customs cells.
Is it possible to do this when I create a MyListViewActivity inside MainActivity? Or does anyone have an idea how to solve this?
The easiest way to do it (it all depends on your implementation) is just to use
setContentView(R.layout.new_layout)on button click, which will inflate the other layout inside the same activity, replacing the old layout. BUT then be careful that all menus/action bars still get inflated, and that you don’t reference any widgets which exist on the old layout.If you want to have just a small section appear inside of your main layout, in your xml you could have something like:
then on the button press you find the reference to small_layout_1, make visibility=gone, find small_layout_2 and make visibility=visible, which will achieve the same behaviour I think you’re looking for