TrulyXax TrulyXax - 1 month ago 5
Android Question

Changing displaying layout on button click

I have a custom circle layout with rotation feature and 4 views as buttons.
On main_activity i have 2 layouts :
-circle layout
-relative layout(Container)

What i want is:
-when the user taps on a button from circle layout, i want the container to be changed with another layout with another views.

This is the initialization of container:

displayLayout = (RelativeLayout) findViewById(;

Initialization of Circle layout:

circleLayout = (CircleLayout) findViewById(;

The tap event occurs on this method:

public void onItemClick(View view) {

-- What should i do here? --

I want that the new xml (newpage.xml) to be replaced in container.

Any sugestions to be done?
Thanks a lot!


you need to do it with fragments as shown in below, to replace view

check fragments in android(

public void onItemClick(View view) {
        // Create new fragment and transaction
        Fragment newFragment = new ExampleFragment();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack if needed
        transaction.replace(, newFragment);
        // Commit the transaction


check example