2013-05-23 1 views
0

이 방법을 사용하여 ListView 항목의 드롭 다운 메뉴를 만듭니다. 여기 Android get List 다른 하위 항목의 하위 항목

는 "의 getView (INT 위치보기 convertView, ViewGoup의 부모)", 사용자 클릭이 "btnMenu"나는 "dropMenu"표시를 설정합니다 경우에 그래서 내 항목의 XML

<RelativeLayout ...> 
    <TableLayout ...> 
    <Something like TextView, ImageView... /> 
    <ImageButton android:id="@+id/btnMenu"... /> 
    </TableLayout> 

    <LinearLayout android:id="@+id/dropMenu" android:visibility="gone" ...> 
    <Some other Button... /> 
    </LinearLayout> 
</RelativeLayout> 

, 그리고 그 드롭 다운 메뉴처럼 보입니다.

내 질문은 "나는, 6 항목을 클릭하여 해당 드롭 다운 메뉴 프로그램을 내가 4 번째 항목을 클릭하여 해당 드롭 다운 메뉴는

  • 두 번째 표시 할

    1. 우선하지만 4 항목의 드롭 다운 메뉴 설정해야합니다 지나간".
    2. 여기

    나는 시도하지만

    View lastView=getChildAt(lastIndex); 
    lastView.findViewById(R.id.dropMenu).setVisibility(View.GONE); 
    

    가 어떻게 때 실제로 6 목록 항목에서 4 번째 목록 항목을 조작 할 수 있습니다 작동 않았다이야?

  • +0

    위의 링크를 참조하십시오, 내가 그것을 확장 가능한 목록보기라고 생각 http://www.coderzheaven.com/expandable-listview-android-simpleexpandablelistadapter-simple-example/ – Hemant

    답변

    0

    ExpandAnimation을 사용하여 요구 사항을 충족시킬 수 있습니다. 완벽하게 구현을 위해 ExpandListItem.java

    package com.list.animation; 
    
    import android.view.View; 
    import android.view.animation.Animation; 
    import android.view.animation.Transformation; 
    import android.widget.LinearLayout.LayoutParams; 
    
    public class ExpandListItem extends Animation { 
        private View mAnimatedView; 
        private LayoutParams mViewLayoutParams; 
        private int mMarginStart, mMarginEnd; 
        private boolean mIsVisibleAfter = false; 
        private boolean mWasEndedAlready = false; 
    
        /** 
        * Initialize the animation 
        * @param view The layout we want to animate 
        * @param duration The duration of the animation, in ms 
        */ 
        public ExpandListItem(View view, int duration) { 
    
         setDuration(duration); 
         mAnimatedView = view; 
         mViewLayoutParams = (LayoutParams) view.getLayoutParams(); 
    
         // decide to show or hide the view 
         mIsVisibleAfter = (view.getVisibility() == View.VISIBLE); 
    
         mMarginStart = mViewLayoutParams.bottomMargin; 
         mMarginEnd = (mMarginStart == 0 ? (0- view.getHeight()) : 0); 
    
         view.setVisibility(View.VISIBLE); 
        } 
    
        @Override 
        protected void applyTransformation(float interpolatedTime, Transformation t) { 
         super.applyTransformation(interpolatedTime, t); 
    
         if (interpolatedTime < 1.0f) { 
    
          // Calculating the new bottom margin, and setting it 
          mViewLayoutParams.bottomMargin = mMarginStart 
            + (int) ((mMarginEnd - mMarginStart) * interpolatedTime); 
    
          // Invalidating the layout, making us seeing the changes we made 
          mAnimatedView.requestLayout(); 
    
         // Making sure we didn't run the ending before (it happens!) 
         } else if (!mWasEndedAlready) { 
          mViewLayoutParams.bottomMargin = mMarginEnd; 
          mAnimatedView.requestLayout(); 
    
          if (mIsVisibleAfter) { 
           mAnimatedView.setVisibility(View.GONE); 
          } 
          mWasEndedAlready = true; 
         } 
        } 
    } 
    

    enter image description here

    enter image description here

    는 아래의 게시물을 통해

    http://amitandroid.blogspot.in/2013/03/android-listview-with-animation.html

    희망이 의지의 시간을 이동 elp you .. 감사합니다

    관련 문제