2017-01-07 7 views
1

「main2-1」、「main2-2」、「main2-2」の中に「main1」(展開可能なアイテム) "main3-1"、 "main3-2"、 "main3-3"(通常の項目)の中の "main2-3"(拡張可能項目)折りたたまれていない展開可能なアイテム内の1つのアイテムのみを展開する

"main2"のレベルで1つのExpandedItem main2-1,2-1,2-3) も ​​"main1"のレベルで

私は試しましたresult.getAdapter().withOnlyOneExpandedItem(true); "結果"は私が使用している引き出しライブラリです - それは崩壊 "main2レベルの最初のアイテムを展開する代わりにレベル

また、this方法が異なる拡張可能なアイテムの第三クリックで動作しません - 私はアプリがそれに入ることを確認するためのログと番目のコードまでを追ったが、それは崩壊しない以前の

if(previousExpandableItemPosition != position) { 
    result.getAdapter().collapse(previousExpandableItemPosition); 
    previousExpandableItemPosition = position; 
} 

答えて

0

私はそのうちの一つを拡大しているために、私が欲しいの拡大の項目のonClickに配置された方法を行っているし、ここでは

if (position != previousPosition && previousPosition != 0 && previousIdentifier != drawerItem.getIdentifier()) { // WithOnlyOneExpandableItem 
           IDrawerItem itemx = result.getAdapter().getItem(previousPosition); 
           if (itemx.isExpanded()) { 
            itemx.withIsExpanded(true); 
            result.updateItem(itemx); 
           } else { 
            if(previousPosition > position){ // user is going upward 
             itemx = result.getAdapter().getItem(previousPosition + result.getAdapter().getItem(position).getSubItems().size()); 
             if (itemx.isExpanded()) { 
              itemx.withIsExpanded(true); 
              result.updateItem(itemx); 
             }else{Log.i("ppppppppppppp", String.valueOf(previousPosition + (previousPosition - position)));} 

            }else if(previousPosition > position){ // user is going downward 
             itemx = result.getAdapter().getItem(previousPosition + (previousPosition 
               + result.getAdapter().getItem(previousPosition).getSubItems().size())); 
             if (itemx.isExpanded()) { 
              itemx.withIsExpanded(true); 
              result.updateItem(itemx); 
             }else{Log.i("ppppppppppppp", String.valueOf(previousPosition + (previousPosition - position)));} 
            } 
           } 
          } else if (previousPosition != 0 && previousIdentifier == drawerItem.getIdentifier()) { 
           //if the drawer item is collapsed after expanding then deselect it 
           EnterTimes++; 
           if(!result.getAdapter().getItem(position).isExpanded()){ 
            EnterTimes=1; 
           } 
           if(EnterTimes <2){ 
            result.getAdapter().getItem(position).withSetSelected(false); 
            result.updateItem(drawerItem); 
           } 
          } 
          previousIdentifier = (int) drawerItem.getIdentifier(); 
           previousPosition = position; 

とのonCreate前int previousPosition = 0, previousIdentifier = 0;

他の誰を支援することです
関連する問題