You can not change the content of a <include>
, but you can do so in a ViewGroup. , because you can add and remove views from it.
At the place where you want to replace one view with another place a FrameLayout and give it an ID .
Create an xml for each of these views .
Create an object for each of them:
view1 = getLayoutInflater().inflate(R.layout.view1, null);
view2 = getLayoutInflater().inflate(R.layout.view2, null);
Get the reference to FrameLayout :
frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
Add the first view to FrameLayout :
frameLayout.addView(layout1);
When you want to change view , remove views from FrameLayout and add the new
frameLayout.removeAllViews();
frameLayout.addView(layout2);
If you just want to put text when the list is empty, check out this answer .