Java 类android.widget.ExpandableListView 实例源码

项目:yyox    文件:ExpandedListUtils.java   
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);
}
项目:chromium-for-android-56-debug-video    文件:RecentTabsPage.java   
/**
 * 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();
}
项目:GitHub    文件:GoodsListActivity.java   
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;
            }
        }
    });
}
项目:yyox    文件:OrderPackageDetailActivity.java   
@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;
                }
            }
        });
    }
}
项目:yyox    文件:ExpandedListUtils.java   
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);
}
项目:TimeTrix    文件:FragmentTagNotes.java   
@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 ();

    }
项目:ywApplication    文件:SearchFragment.java   
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);
                }
            }
        }
    });
}
项目:AssistantBySDK    文件:IntroduceFragment.java   
@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);
                }
            }
        }
    });
}
项目:easyfilemanager    文件:RootsFragment.java   
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;
                }
            }
        }
    }
}
项目:easyfilemanager    文件:RootsFragment.java   
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;
    }
}
项目:chromium-for-android-56-debug-video    文件:RecentTabsPage.java   
@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);
    }
}
项目:cat-is-a-dog    文件:FollowingHabitsFragment.java   
/**
 * 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;
}
项目:expandableListviewDemo    文件:MainActivity.java   
@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);
    }
}
项目:simple-share-android    文件:RootsFragment.java   
@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;
}
项目:letv    文件:VipFragment.java   
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);
    }
}
项目:simple-share-android    文件:RootsFragment.java   
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;
    }
}
项目:Android-BLE-to-Arduino    文件:DeviceControlActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    mDataField = (TextView) findViewById(R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
项目:FireFiles    文件:RootsFragment.java   
@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;
}
项目:letv    文件:ChannelDetailExpandableListAdapter.java   
public void setDataList(ExpandableListView listView, ChannelHomeBean homeBean, boolean isFromNet) {
    if (homeBean != null && !BaseTypeUtils.isListEmpty(homeBean.block) && listView != null) {
        this.mList.clear();
        Iterator it = homeBean.block.iterator();
        while (it.hasNext()) {
            HomeBlock block = (HomeBlock) it.next();
            if (block != null && (!BaseTypeUtils.isListEmpty(block.list) || "2".equals(block.contentStyle))) {
                this.mList.add(block);
            }
        }
        this.mIsFromNet = isFromNet;
        if (BaseTypeUtils.getElementFromList(homeBean.block, homeBean.tabIndex) != null) {
            this.mStartRank = 1;
        } else {
            this.mStartRank = 0;
        }
        notifyDataSetChanged();
        for (int i = 0; i < getGroupCount(); i++) {
            listView.expandGroup(i);
        }
        listView.setGroupIndicator(null);
        listView.setOnGroupClickListener(new 1(this));
        this.mIsRehreshVipData = true;
    }
}
项目:linkedout_procon    文件:Profile.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    prefs = getContext().getSharedPreferences(STUDENT_PREFS, 0);

    View view =  inflater.inflate(R.layout.fragment_profile, container, false);

    fillInData(view);

    // get the listview
    expListView = (ExpandableListView) view.findViewById(R.id.lvExp);

    prepareListData();
    listAdapter = new ExpandableListAdapter(view.getContext(), listDataHeader, listDataChild);

    // setting list adapter
    expListView.setAdapter(listAdapter);

    return view;
}
项目:Huochexing12306    文件:A6OrderAty.java   
private void initViews() {
    mNavigationIndex = getIntent()
            .getIntExtra(EXTRA_PRE_LOAD_DATA_INDEX, 0);
    llytOperate = (LinearLayout) findViewById(R.id.operate);
    btnCancel = (Button) findViewById(R.id.cancel);
    btnCancel.setOnClickListener(this);
    btnPay = (Button) findViewById(R.id.pay);
    btnPay.setOnClickListener(this);
    tvEmptyView = (TextView) findViewById(R.id.emptyView);
    lvOrders = (ExpandableListView) findViewById(R.id.orders);

    lvOrders.setEmptyView(tvEmptyView);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View footerView = inflater.inflate(R.layout.fv_a6_order, null);
    lvOrders.addFooterView(footerView);
    mAdapter = new A6OrderExpandableAdapter(this, mLstODBInfos);
    lvOrders.setAdapter(mAdapter);

    // btnPay.setEnabled(false);
    setPanelGone(true);
}
项目:exciting-app    文件:ExpandableHListPosition.java   
static ExpandableHListPosition obtainPosition(long packedPosition) {
    if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
        return null;
    }

    ExpandableHListPosition elp = getRecycledOrCreate();
    elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
    if (ExpandableListView.getPackedPositionType(packedPosition) ==
            ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        elp.type = CHILD;
        elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
    } else {
        elp.type = GROUP;
    }
    return elp;
}
项目:Android-DFU-App    文件:ExpandableListActivity.java   
/**
 * Updates the screen state (current list and other views) when the content changes.
 * 
 * @see android.support.v7.app.AppCompatActivity#onContentChanged()
 */
@Override
public void onContentChanged() {
    super.onContentChanged();
    View emptyView = findViewById(R.id.empty);
    mList = (ExpandableListView) findViewById(R.id.list);
    if (mList == null) {
        throw new RuntimeException(
                "Your content must have a ExpandableListView whose id attribute is " +
                        "'R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnChildClickListener(this);
    mList.setOnGroupExpandListener(this);
    mList.setOnGroupCollapseListener(this);

    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mFinishedStart = true;
}
项目:igrow-android    文件:DeviceControlActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.igrow.android.R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(com.igrow.android.R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(com.igrow.android.R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(com.igrow.android.R.id.connection_state);
    mDataField = (TextView) findViewById(com.igrow.android.R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
项目:simple-share-android    文件:RootsFragment.java   
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;
                }
            }
        }
    }
}
项目:CIA    文件:ViewHabitIntentTests.java   
/**
 * Select the first habit in the user's list
 * @return the name of the first habit
 */
private String loadHabit(){
    // expand the first category
    solo.clickOnView(((ExpandableListView)solo.getView(R.id.HabitTypeExpandableListView)).getAdapter().getView(0, null, null));
    solo.sleep(600);

    String habitName = (String) ((ExpandableListView)solo.getView(R.id.HabitTypeExpandableListView)).getAdapter().getItem(1);

    // click in the first habit in the category
    solo.clickInList(2, 0);
    solo.sleep(1500);

    solo.assertCurrentActivity("wrong activity", HabitViewActivity.class);
    return habitName;
}
项目:ultrasonic    文件:PullToRefreshExpandableListView.java   
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
    final ExpandableListView lv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        lv = new InternalExpandableListViewSDK9(context, attrs);
    } else {
        lv = new InternalExpandableListView(context, attrs);
    }

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
项目:CustomListView    文件:PullToRefreshExpandableListView.java   
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
    final ExpandableListView lv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        lv = new InternalExpandableListViewSDK9(context, attrs);
    } else {
        lv = new InternalExpandableListView(context, attrs);
    }

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
项目:ywApplication    文件:PullToRefreshExpandableListView.java   
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
    final ExpandableListView lv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        lv = new InternalExpandableListViewSDK9(context, attrs);
    } else {
        lv = new InternalExpandableListView(context, attrs);
    }

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
项目:CSipSimple    文件:WizardChooser.java   
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    Map<String, Object> data = childDatas.get(groupPosition).get(childPosition);
    String wizard_id = (String) data.get(WizardUtils.ID);

    Intent result = getIntent();
    result.putExtra(WizardUtils.ID, wizard_id);

    setResult(RESULT_OK, result);
    finish();

    return true;
}
项目:homebank_android    文件:BudgetSummaryFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.category_list, container, false);
    expandableListView = (ExpandableListView) rootView.findViewById(R.id.expandable_category_list);
    addOnClickListeners();
    listAdapter = new ExpandableCategoryAdapter(
            getActivity(),
            HomeActivity.xhb.getTopCategoriesForMonthlyBudget(HomeActivity.CURRENT_MONTH),
            HomeActivity.CURRENT_MONTH
    );
    expandableListView.setAdapter(listAdapter);
    return rootView;
}
项目:easyfilemanager    文件:RootsFragment.java   
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
项目:simple-share-android    文件:RootsFragment.java   
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
项目:easyfilemanager    文件:RootsFragment.java   
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    int itemType = ExpandableListView.getPackedPositionType(id);
    int childPosition;
    int groupPosition;

    if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        childPosition = ExpandableListView.getPackedPositionChild(id);
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
        if (item instanceof AppItem) {
            showAppDetails(((AppItem) item).info);
            return true;
        } else if (item instanceof BookmarkItem) {
            removeBookark((BookmarkItem)item);
            return true;
        }  else {
            return false;
        }

    } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        return false;

    } else {
        return false;
    }
}
项目:easyfilemanager    文件:RootsFragment.java   
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
项目:Hotspot-master-devp    文件:PullToRefreshExpandableListView.java   
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
    final ExpandableListView lv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        lv = new InternalExpandableListViewSDK9(context, attrs);
    } else {
        lv = new InternalExpandableListView(context, attrs);
    }

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
项目:NoticeDog    文件:InboxCursorAdapter.java   
private InboxCursorAdapter(Context context, Cursor cursor, final ExpandableListView parent) {
    super(cursor, context);
    GuiceModule.get().injectMembers(this);
    this.context = context;
    this.parent = parent;
    SwipeDismissListViewTouchListener touchListener = new SwipeDismissListViewTouchListener(parent, new SwipeDismissListViewTouchListener.DismissCallbacks() {
        public boolean canDismiss(int position) {
            return true;
        }

        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int reverseSortedPosition : reverseSortedPositions) {
                long packedPosition = parent.getExpandableListPosition(reverseSortedPosition);
                int type = ExpandableListView.getPackedPositionType(packedPosition);
                int groupPosition;
                if (type == 1) {
                    groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
                    int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
                    Log.d(InboxCursorAdapter.TAG, "Removing group = " + groupPosition + "  |  child = " + childPosition + "  |  global position = " + reverseSortedPosition);
                    InboxCursorAdapter.this.inboxManager.deleteMessage(InboxCursorAdapter.this.inboxManager.getMessageFromViewCursor(InboxCursorAdapter.this.getChild(groupPosition, childPosition)));
                    InboxCursorAdapter.this.reset();
                } else if (type == 0) {
                    groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
                    Log.d(InboxCursorAdapter.TAG, "Removing group = " + groupPosition + "  |  global position = " + reverseSortedPosition);
                    InboxCursorAdapter.this.inboxManager.deleteConversation(InboxCursorAdapter.this.inboxManager.getConversationFromViewCursor(InboxCursorAdapter.this.getGroup(groupPosition)));
                    InboxCursorAdapter.this.reset();
                }
            }
        }
    });
    touchListener.setSwipeToDismissViewResourceId(R.id.swipe_to_dismiss_view);
    parent.setOnTouchListener(touchListener);
    parent.setOnScrollListener(touchListener.makeScrollListener());
    parent.setSelector(17170445);
}
项目:CustomAndroidOneSheeld    文件:PullToRefreshExpandableListView.java   
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
    final ExpandableListView lv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        lv = new InternalExpandableListViewSDK9(context, attrs);
    } else {
        lv = new InternalExpandableListView(context, attrs);
    }

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
项目:simple-share-android    文件:RootsFragment.java   
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
项目:Veggietizer    文件:Popup.java   
/**
 * Shows the popup that is opened when the user clicks on the info action button of a details page.
 * An {@link ExpandableListView} is used as a layout.
 *
 * @param context The context to show the popup in.
 * @param title The popup's title.
 * @param groups The expandable categories.
 * @param entries Each category in <code>groups</code> shows one entry when expanded.
 * @return The dialog.
 */
private static AlertDialog showDetailsInfo(Context context, String title,
                                           String[] groups, String[] entries,
                                           DialogInterface.OnClickListener onSubmitListener) {
    if (groups.length != entries.length) {
        throw new IllegalArgumentException();
    }

    // Custom title
    TextView customTitle = (TextView) LayoutInflater.from(context).inflate(R.layout.popup_title, null);
    customTitle.setText(title);

    View popupDetailsInfo = LayoutInflater.from(context)
            .inflate(R.layout.popup_details_info, null);
    ExpandableListView listViewDetailsInfo = (ExpandableListView)
            popupDetailsInfo.findViewById(R.id.expandablelistview_popup_details_info);
    ExpandableListAdapter adapter = createDetailsInfoAdapter(context, groups, entries);
    listViewDetailsInfo.setAdapter(adapter);

    AlertDialog.Builder popupBuilder = new AlertDialog.Builder(context);
    popupBuilder.setView(popupDetailsInfo)
            .setNeutralButton(R.string.ok, onSubmitListener)
            .setCustomTitle(customTitle);

    AlertDialog dialog = popupBuilder.create();
    dialog.show();

    Utility.setFont(FontManager.Font.ROBOTO_LIGHT, new TextView[]{
            customTitle
    });

    return dialog;
}