private void updateButtonsLayout ( ) { // Get the buttons layout. LinearLayout root = this . chooser . getRootLayout ( ) ; LinearLayout buttonsLayout = ( LinearLayout ) root . findViewById ( R . id . linearLayoutButtons ) ; // Verify if the 'Add' button is visible or not. View addButton = root . findViewById ( R . id . buttonAdd ) ; addButton . setVisibility ( this . canCreateFiles ? View . VISIBLE : View . INVISIBLE ) ; addButton . getLayoutParams ( ) . width = this . canCreateFiles ? ViewGroup . LayoutParams . MATCH_PARENT : 0 ; // Verify if the 'Ok' button is visible or not. View okButton = root . findViewById ( R . id . buttonOk ) ; okButton . setVisibility ( this . folderMode ? View . VISIBLE : View . INVISIBLE ) ; okButton . getLayoutParams ( ) . width = this . folderMode ? ViewGroup . LayoutParams . MATCH_PARENT : 0 ; // If both buttons are invisible, hide the layout. ViewGroup . LayoutParams params = buttonsLayout . getLayoutParams ( ) ; if ( this . canCreateFiles || this . folderMode ) { // Show the layout. params . height = ViewGroup . LayoutParams . WRAP_CONTENT ; // If only the 'Ok' button is visible, put him first. Otherwise, put 'Add' first. buttonsLayout . removeAllViews ( ) ; if ( this . folderMode && ! this . canCreateFiles ) { buttonsLayout . addView ( okButton ) ; buttonsLayout . addView ( addButton ) ; } else { buttonsLayout . addView ( addButton ) ; buttonsLayout . addView ( okButton ) ; } } else { // Hide the layout. params . height = 0 ; } }
Changes the height of the layout for the buttons according if the buttons are visible or not .