当前位置: 首页>>代码示例>>Java>>正文


Java ExpandableListView类代码示例

本文整理汇总了Java中android.widget.ExpandableListView的典型用法代码示例。如果您正苦于以下问题:Java ExpandableListView类的具体用法?Java ExpandableListView怎么用?Java ExpandableListView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExpandableListView类属于android.widget包,在下文中一共展示了ExpandableListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setExpandedListViewHeightBasedOnChildren

import android.widget.ExpandableListView; //导入依赖的package包/类
public static void setExpandedListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height += appendHeight;
    listView.setLayoutParams(params);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:17,代码来源:ExpandedListUtils.java

示例2: RecentTabsPage

import android.widget.ExpandableListView; //导入依赖的package包/类
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:RecentTabsPage.java

示例3: initExpandableListView

import android.widget.ExpandableListView; //导入依赖的package包/类
private void initExpandableListView() {
    group = new ArrayList<>();
    child = new ArrayList<>();
    //去掉默认箭头
    listView.setGroupIndicator(null);
    addInfo("全部", new String[]{});
    addInfo("上衣", new String[]{"古风", "和风", "lolita", "日常"});
    addInfo("下装", new String[]{"日常", "泳衣", "汉风", "lolita", "创意T恤"});
    addInfo("外套", new String[]{"汉风", "古风", "lolita", "胖次", "南瓜裤", "日常"});

    // 这里是控制如果列表没有孩子菜单不展开的效果
    listView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent,
                                    View v, int groupPosition, long id) {
            if (child.get(groupPosition).isEmpty()) {// isEmpty没有
                return true;
            } else {
                return false;
            }
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:GoodsListActivity.java

示例4: setUIValue

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
public void setUIValue(OrderDetail orderDetailJson) {
    for (int i = 0; i < orderDetailJson.getMerchandiseList().size(); i++) {
        if (orderDetailJson.getMerchandiseList().size() != 1) {
            mExpandableListView.collapseGroup(i);
        } else {
            mExpandableListView.expandGroup(i);
        }
        mExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                if (orderDetailJson.getMerchandiseList().size() != 1) {
                    return false;
                } else {
                    return true;
                }
            }
        });
    }
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:21,代码来源:OrderPackageDetailActivity.java

示例5: setCollapseListViewHeightBasedOnChildren

import android.widget.ExpandableListView; //导入依赖的package包/类
public static void setCollapseListViewHeightBasedOnChildren(ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height -= appendHeight;
    listView.setLayoutParams(params);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:17,代码来源:ExpandedListUtils.java

示例6: onActivityCreated

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated (savedInstanceState);
        ImageButton btnAddNotes = (ImageButton) getActivity ().findViewById (R.id.buttonAddNotesTags);
        btnAddNotes.setOnClickListener (this);
        btnAddNotes.setVisibility (View.INVISIBLE);
//        ListView mListViewTag = (ListView) getActivity().findViewById(R.id.listNotesAll);

        mExpandableListViewTag = (ExpandableListView) getActivity ().findViewById (R.id.expandableListNotesTags);

        mArrayListTagNotes = new ArrayList<> ();
//        customAdapterTagNotes = new CustomAdapter(mArrayListTagNotes, getActivity(),tempString , mHandler);
        mCustomAdapterTags = new CustomAdapterTags (getActivity (), Integer.parseInt (mSectionIndex) + 1);
        mExpandableListViewTag.setTag (R.string.filename, mSectionIndex);
        mExpandableListViewTag.setTag (R.string.list_object, mArrayListTagNotes);
        mExpandableListViewTag.setAdapter (mCustomAdapterTags);
        mExpandableListViewTag.setItemsCanFocus (true);
        registerForContextMenu (mExpandableListViewTag);
        mSectionIndex = String.valueOf (mOnFragmentInteractionListener.getSectionIndex());
        populateListView ();

    }
 
开发者ID:atulgpt,项目名称:TimeTrix,代码行数:23,代码来源:FragmentTagNotes.java

示例7: initView

import android.widget.ExpandableListView; //导入依赖的package包/类
private void initView(View view) {
    expandableListView = (ExpandableListView) view.findViewById(R.id.search_listview);
    heardView = inflater.inflate(R.layout.search_item_heard_view, expandableListView, false);
    setclickListener(heardView);
    contantsAdapter = new ContantsAdapter(getActivity(), groupImgId, text, datas,numId);
    expandableListView.setAdapter(contantsAdapter);
    expandableListView.addHeaderView(heardView);
    expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
        @Override
        public void onGroupExpand(int groupPosition) {
            for (int i = 0; i <groupImgId.size() ; i++) {
                if (groupPosition !=i) {
                    expandableListView.collapseGroup(i);
                }
            }
        }
    });
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:19,代码来源:SearchFragment.java

示例8: onActivityCreated

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inflater=LayoutInflater.from(getActivity());
    listAdapter=new ExpandableListAdapter(getActivity());
    listView.setAdapter(listAdapter);
    listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {

        @Override
        public void onGroupExpand(int groupPosition) {
            for(int i = 0; i < listAdapter.getGroupCount(); i++){
                if(i != groupPosition && listView.isGroupExpanded(i)){
                    listView.collapseGroup(i);
                }
            }
        }
    });
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:19,代码来源:IntroduceFragment.java

示例9: onCurrentRootChanged

import android.widget.ExpandableListView; //导入依赖的package包/类
public void onCurrentRootChanged() {
    if (mAdapter == null || mList == null) return;

    final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
    for (int i = 0; i < mAdapter.getGroupCount(); i++) {
        for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
            final Object item = mAdapter.getChild(i,j);
            if (item instanceof RootItem) {
                final RootInfo testRoot = ((RootItem) item).root;
                if (Objects.equal(testRoot, root)) {
                    try {
                        long id = ExpandableListView.getPackedPositionForChild(i, j);
                        int index = mList.getFlatListPosition(id);
                        //mList.setSelection(index);
                        mList.setItemChecked(index, true);
                    } catch (Exception e){
                        CrashReportingManager.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:26,代码来源:RootsFragment.java

示例10: getExpandedIds

import android.widget.ExpandableListView; //导入依赖的package包/类
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:17,代码来源:RootsFragment.java

示例11: onCreateContextMenu

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:RecentTabsPage.java

示例12: onCreateView

import android.widget.ExpandableListView; //导入依赖的package包/类
/**
 * Instantiate our data sources with firebase and our list adapters / view bindings
 * @param inflater
 * @param container
 * @param savedInstanceState
 * @return
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_following_habits, container, false);

    ExpandableListView followingHabitsView =
            (ExpandableListView) view.findViewById(R.id.following_habits_list);

    String userId = CurrentUser.getInstance().getUserId();

    followingDataSource = new SocialDataSource(userId, SocialDataSource.UserType.FOLLOWING);
    followingDataSource.addObserver(this);
    following = followingDataSource.getSource();

    followingHabitsAdapter = new FollowingHabitsListAdapter(
            getActivity(),
            following,
            followingHabitMap
            );

    followingHabitsView.setAdapter(followingHabitsAdapter);

    return view;
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:32,代码来源:FollowingHabitsFragment.java

示例13: onCreate

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView = (ExpandableListView) findViewById(R.id.expandableListView);
    listView.setGroupIndicator(null);
    /**
     * 初始化数据
     */
    initData();
    adapter = new ExAdapter(this, lines);
    listView.setAdapter(adapter);
    //遍历所有group,将所有项设置成默认展开
    int groupCount = listView.getCount();
    for (int i = 0; i < groupCount; i++) {
        listView.expandGroup(i);
    }
}
 
开发者ID:Glorylan,项目名称:expandableListviewDemo,代码行数:20,代码来源:MainActivity.java

示例14: onChildClick

import android.widget.ExpandableListView; //导入依赖的package包/类
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                            int childPosition, long id) {
    final BaseActivity activity = BaseActivity.get(RootsFragment.this);
    final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
    if (item instanceof RootItem) {
            int index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
        parent.setItemChecked(index, true);
        activity.onRootPicked(((RootItem) item).root, true);
        Bundle params = new Bundle();
        params.putString("type", ((RootItem) item).root.title);
        AnalyticsManager.logEvent("navigate", ((RootItem) item).root, params);
    } else if (item instanceof AppItem) {
        activity.onAppPicked(((AppItem) item).info);
    } else {
        throw new IllegalStateException("Unknown root: " + item);
    }
    return false;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:20,代码来源:RootsFragment.java

示例15: setRootView

import android.widget.ExpandableListView; //导入依赖的package包/类
private void setRootView(ChannelHomeBean result, boolean isFromNet) {
    if (result != null) {
        this.mChannelHomeBean = result;
        if (!BaseTypeUtils.isListEmpty(this.mChannelHomeBean.searchWords)) {
            initFooterSearchView(this.mChannelHomeBean.searchWords);
        }
        setFocusView(this.mChannelHomeBean.focus);
        if (this.mChannelHomeBean.isShowTextMark) {
            setVipTipsView();
        }
        initTabView(result);
        finishLoading();
        this.mPullView.setPullToRefreshEnabled(true);
        ((ExpandableListView) this.mPullView.getRefreshableView()).setAdapter(this.mListAdapter);
        this.mListAdapter.setDataList((ExpandableListView) this.mPullView.getRefreshableView(), this.mChannelHomeBean, isFromNet);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:VipFragment.java


注:本文中的android.widget.ExpandableListView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。