I have a Fragment and partial code from my app is:
mFrame3 = (RelativeLayout) inflater.inflate( R.layout.ptrip, container, false ); //display if file exist
noFilesDisplayed = (RelativeLayout) inflater.inflate(R.layout.nofile, container, false); //display if file doesn't exist
if (FilesInFolder != null) { //function to check if any file exist
mFrame3.findViewById(R.layout.ptrip).setVisibility(View.VISIBLE); //display this layout
noFilesDisplayed.findViewById(R.layout.nofile).setVisibility(View.GONE); //hide this layout
}
else {
mFrame3.findViewById(R.layout.ptrip).setVisibility(View.GONE);
noFilesDisplayed.findViewById(R.layout.nofile).setVisibility(View.VISIBLE);
}
I am not sure if it's the best way but what I am looking to do is if there are any files in the directory to show the mFrame3
RelativeLayout XML file and hide noFilesDisplayed
otherwise show the noFilesDisplayed
RelativeLayout XML file and hide mFrame3
.