content: package com.quizapp.tollywood.swipelistview;
  
  import java.util.List;
  
  import com.quizapp.tollywood.widgets.QuizAppMenuItem;
  
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.LinearLayout;
  
  /**
  
   * 
   * @author baoyz
   * @date 2014-8-23
   * 
   */
  public class SwipeMenuView extends LinearLayout implements OnClickListener {
  
  	private SwipeMenuListView mListView;
  	private SwipeMenuLayout mLayout;
  	private SwipeMenu mMenu;
  	private OnItemClickListener onItemClickListener;
  	private int position;
  
  	public int getPosition() {
  		return position;
  	}
  
  	public void setPosition(int position) {
  		this.position = position;
  	}
  
  	public SwipeMenuView(SwipeMenu menu, SwipeMenuListView listView) {
  		super(menu.getContext());
  		mListView = listView;
  		mMenu = menu;
  		List<SwipeMenuItem> items = menu.getMenuItems();
  		int id = 0;
  		for (SwipeMenuItem item : items) {
  			addItem(item, id++);
  		}
  	}
  
  	protected void addItem(SwipeMenuItem item, int id) {
  		addView(new QuizAppMenuItem(item.mContext, id, item.getBgColor() , 0 , item.getTitle())); 
  	}
  
  	@Override
  	public void onClick(View v) {
  		if (onItemClickListener != null && mLayout.isOpen()) {
  			onItemClickListener.onItemClick(this, mMenu, v.getId());
  		}
  	}
  
  	public OnItemClickListener getOnItemClickListener() {
  		return onItemClickListener;
  	}
  
  	public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
  		this.onItemClickListener = onItemClickListener;
  	}
  
  	public void setLayout(SwipeMenuLayout mLayout) {
  		this.mLayout = mLayout;
  	}
  
  	public static interface OnItemClickListener {
  		void onItemClick(SwipeMenuView view, SwipeMenu menu, int index);
  	}
  }
  