popupwindow的二级Listview的联动菜单、ListView形式的菜单、GridView形式的菜单的Util。
资源地址:http://download.csdn.net/detail/izheer/9642741
popupwindow的子布局无外乎就是那几个形式:listview、gridview、listview二级联动等。因此,我将它们都写成了util类,只需要将item的onClick事件单独引出来,使用者将数据源以及控件对象传入即可。具体效果见下:
二级联动Listview菜单
util类:
package izheer.com.utils;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import java.util.List;
import izheer.com.popupwindowutil.R;
/**
* 二级菜单 popWindow
* Created by Administrator on 2016/9/19.
*/
public abstract class DoubleListPopViewUtil {
private Context context;
private View view;//在哪个view的下面
//数据源
private List<String> roots;//根目录的节点
private List<List<String>> sub_items;// 子目录节点
private PopupWindow areaPopupWindow;
private RootListViewAdapter rootAdapter;
private SubListViewAdapter subAdapter;
public abstract void onRootListviewOnClick(View v, int position);//根布局的item的点击事件
public abstract void onSubListviewOnClick(View v, int position);//二级菜单的item的点击事件
public DoubleListPopViewUtil(Context context, View view, List<String> roots, List<List<String>> sub_items) {
this.context = context;
this.view = view;
this.roots = roots;
this.sub_items = sub_items;
init();
}
private void init(){
LayoutInflater inflater = LayoutInflater.from(context);
final LinearLayout areaPopupLayout = (LinearLayout) inflater.inflate(R.layout.a