类android.widget.ExpandableListView源码实例Demo

下面列出了怎么用android.widget.ExpandableListView的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AnyTime   文件: DoingListFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View rootView = inflater.inflate(R.layout.fragment_main_doing_list,
			container, false);
	mDoingListData = new ArrayList<DoingListData>();
	expandableListView = (ExpandableListView) rootView
			.findViewById(R.id.expandableListView_doing_list);
	adapter = new AnytimeExpandableListAdapter(activity);
	expandableListView.setAdapter(adapter);
	expandableListView.setOnChildClickListener(listener);
	messageText = (TextView) rootView
			.findViewById(R.id.textView_loading_wait);
	LoadingData();
	return rootView;
}
 
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                            int childPosition, long id) {
    if (mGattCharacteristics != null) {
        final BluetoothGattCharacteristic characteristic =
                mGattCharacteristics.get(groupPosition).get(childPosition);
        final int charaProp = characteristic.getProperties();
        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
            // If there is an active notification on a characteristic, clear
            // it first so it doesn't update the data field on the user interface.
            if (mNotifyCharacteristic != null) {
                mBluetoothLeService.setCharacteristicNotification(
                        mNotifyCharacteristic, false);
                mNotifyCharacteristic = null;
            }
            mBluetoothLeService.readCharacteristic(characteristic);
        }
        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
            mNotifyCharacteristic = characteristic;
            mBluetoothLeService.setCharacteristicNotification(
                    characteristic, true);
        }
        return true;
    }
    return false;
}
 
public void setPinnedHeaderView(View view) {
	mHeaderView = view;
	if (mHeaderView != null) {
		setFadingEdgeLength(0);
		mHeaderView.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					final long flatPos = getExpandableListPosition(getFirstVisiblePosition());
					final int groupPos = ExpandableListView
							.getPackedPositionGroup(flatPos);
					collapseGroup(groupPos);
				}
				return true;
			}
		});
	}
	requestLayout();
}
 
源代码4 项目: privacy-friendly-weather   文件: HelpActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_help);
    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
源代码5 项目: AndroidChromium   文件: 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();
}
 
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
	super.onLayout(changed, l, t, r, b);
	final long flatPostion = getExpandableListPosition(getFirstVisiblePosition());
	final int groupPos = ExpandableListView
			.getPackedPositionGroup(flatPostion);
	final int childPos = ExpandableListView
			.getPackedPositionChild(flatPostion);
	int state = mAdapter.getPinnedHeaderState(groupPos, childPos);
	
	if (mHeaderView != null && mAdapter != null && state != mOldState) {
		mOldState = state;
		mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight);
	}

	configureHeaderView(groupPos, childPos);
}
 
private void drawFloatingGroupIndicator(Canvas canvas) {
	final Drawable groupIndicator = (Drawable) ReflectionUtils.getFieldValue(ExpandableListView.class, "mGroupIndicator", FloatingGroupExpandableListView.this);
	if(groupIndicator != null) {
		final int stateSetIndex =
				(mAdapter.isGroupExpanded(mFloatingGroupPosition) ? 1 : 0) | // Expanded?
				(mAdapter.getChildrenCount(mFloatingGroupPosition) > 0 ? 2 : 0); // Empty?
		groupIndicator.setState(GROUP_STATE_SETS[stateSetIndex]);

		final int indicatorLeft = (Integer) ReflectionUtils.getFieldValue(ExpandableListView.class, "mIndicatorLeft", FloatingGroupExpandableListView.this);
		final int indicatorRight = (Integer) ReflectionUtils.getFieldValue(ExpandableListView.class, "mIndicatorRight", FloatingGroupExpandableListView.this);

		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			mIndicatorRect.set(indicatorLeft + getPaddingLeft(), mFloatingGroupView.getTop(), indicatorRight + getPaddingLeft(), mFloatingGroupView.getBottom());
		} else {
			mIndicatorRect.set(indicatorLeft, mFloatingGroupView.getTop(), indicatorRight, mFloatingGroupView.getBottom());
		}

		groupIndicator.setBounds(mIndicatorRect);
		groupIndicator.draw(canvas);
	}
}
 
protected void showNoResultsFoundView(final String emptyMsg) {
	if (parentView == null || TextUtils.isEmpty(emptyMsg)) return;
	
	ExpandableListView lv = (ExpandableListView)parentView.findViewById(R.id.channelListView);
	View emptyView = parentView.findViewById(R.id.channelListEmpty);
	if (lv != null && emptyView != null) {
		TextView tv = (TextView)emptyView.findViewById(R.id.results_not_found);
		tv.setText(emptyMsg);
		
		lv.setEmptyView(emptyView);
	}
	
	View progressView = parentView.findViewById(R.id.channelListProgress);
	if (progressView != null) {
		progressView.setVisibility(View.GONE);
	}
	
}
 
源代码9 项目: TreeView   文件: TreeView.java
private void onHeaderViewClick() {
    long packedPosition = getExpandableListPosition(getFirstVisiblePosition());

    int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);

    int status = mUpdater.getHeaderClickStatus(groupPosition);
    if (ITreeViewHeaderUpdater.STATE_VISIBLE_ALL == status) {
        collapseGroup(groupPosition);
        mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_GONE);
    } else {
        expandGroup(groupPosition);
        mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_VISIBLE_ALL);
    }

    setSelectedGroup(groupPosition);
}
 
源代码10 项目: ui   文件: elvDemo1_Fragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo1_fragment, container, false);


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

	// preparing list data
	prepareListData();

	listAdapter = new ExpandableListAdapter(myContext, listDataHeader, listDataChild);

	// setting list adapter
	expListView.setAdapter(listAdapter);
	
	return myView;
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_generic_expandable_list, container, false);
    ExpandableListView elv = (ExpandableListView) v
            .findViewById(R.id.expandableListView);
    if (mHub.equals("Caravan")) {
        elv.setAdapter(new QuestListAdapter(caravan));
    } else if(mHub.equals("Guild")) {
        elv.setAdapter(new QuestListAdapter(guild));
    } else {
        elv.setAdapter(new QuestListAdapter(event));
    }

    return v;

}
 
源代码12 项目: 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);
    }
}
 
@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);
}
 
源代码14 项目: FireFiles   文件: 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){
                        Crashlytics.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
@Override
protected void onCreate(Bundle savedInstance) {
  super.onCreate(savedInstance);
  setContentView(R.layout.results_expandable_list);

  // get intent from main activity
  Intent intent = getIntent();
  // get the HashMap created in MainActivity
  HashMap<String,ArrayList<String>> child = (HashMap<String,ArrayList<String>>) intent.getSerializableExtra("HashMap");
  ArrayList<String> header = new ArrayList<>();
  header.add("Point");
  header.add("Polyline");
  header.add("Polygon");

  // create an expandable list view and an adapter to display in new activity.
  ExpandableListView expandableListView = findViewById(R.id.expandableList);
  ExpandableListAdapter expandableListAdapter = new ExpandableListAdapter(this,header,child);
  expandableListView.setAdapter(expandableListAdapter);
}
 
源代码16 项目: privacy-friendly-ludo   文件: HelpActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
源代码17 项目: ActivityLauncher   文件: AllTasksListFragment.java
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v,
                                ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            menu.setHeaderIcon(activity.icon);
            menu.setHeaderTitle(activity.name);
            menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
            break;
        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            menu.setHeaderIcon(pack.icon);
            menu.setHeaderTitle(pack.name);
            break;
    }

    super.onCreateContextMenu(menu, v, menuInfo);
}
 
源代码18 项目: SkyTube   文件: CommentsAdapter.java
public CommentsAdapter(Context context, String videoId, ExpandableListView expandableListView, View commentsProgressBar, View noVideoCommentsView) {
	this.context = context;
	this.videoId = videoId;
	this.expandableListView = expandableListView;
	this.expandableListView.setAdapter(this);
	this.expandableListView.setOnGroupClickListener((parent, v, groupPosition, id) -> true);
	this.commentsProgressBar = commentsProgressBar;
	this.noVideoCommentsView = noVideoCommentsView;
	this.layoutInflater = LayoutInflater.from(expandableListView.getContext());
	try {
		this.commentThreadPager = NewPipeService.isPreferred() ? NewPipeService.get().getCommentPager(videoId) : new GetCommentThreads(videoId);
		this.getCommentsTask = new GetCommentsTask();
		this.getCommentsTask.execute();
	} catch (Exception e) {
		SkyTubeApp.notifyUserOnError(context, e);
	}
}
 
源代码19 项目: delion   文件: 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);
    }
}
 
源代码20 项目: privacy-friendly-netmonitor   文件: HelpActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    RunStore.setContext(this);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    HashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
源代码21 项目: FireFiles   文件: 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;
    }
}
 
源代码22 项目: privacy-friendly-pedometer   文件: HelpActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
源代码23 项目: ui   文件: elvDemo2_Fragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo2_fragment, container, false);
	
    // get the listview
       expListView = (ExpandableListView) myView.findViewById(R.id.lvExp2);
       prepareListData();
       
       listAdapter =  new SimpleExpandableListAdapter(
                       myContext,						    //context
                       listDataGroup,                  // group list in the form:  List<? extends Map<String, ?>>
                       R.layout.evl2_group_row,        // Group item layout XML.
                       new String[] { "Group Item" },  // the key of group item.   String[] groupFrom, 
                       new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.  int[] groupTo
                       listDataChild,              // childData describes second-level entries. in the form List<? extends List<? extends Map<String, ?>>>
                       R.layout.evl2_child_row,             // Layout for sub-level entries(second level).
                       new String[] {"Sub Item A", "Sub Item B"},      // Keys in childData maps to display.
                       new int[] { R.id.grp_childA, R.id.grp_childB}     // Data under the keys above go into these TextViews.
                   );
      expListView.setAdapter( listAdapter );       // setting the adapter in the list.
    
       return myView;
}
 
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
	MyLog.entry("menuItem = " + menuItem);

	final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuItem.getMenuInfo();
	final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition);

	//final MonsterInfoModel monsterInfo = getGroupMonsterItem(menuItem.getMenuInfo());

	switch (menuItem.getItemId()) {
		case MENU_ID_SELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, true);
			break;
		case MENU_ID_DESELECT_ALL:
			mAdapter.flagAllChildren(groupPosition, false);
			break;
		default:
	}

	MyLog.exit();
	return true;
}
 
源代码25 项目: document-viewer   文件: OPDSActivity.java
/**
 * {@inheritDoc}
 *
 * @see org.emdev.ui.AbstractActionActivity#onCreateImpl(android.os.Bundle)
 */
@Override
protected void onCreateImpl(final Bundle savedInstanceState) {

    setContentView(R.layout.opds);
    setActionForView(R.id.opdsaddfeed);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    
    final OPDSActivityController c = getController();

    list = (ExpandableListView) findViewById(R.id.opdslist);
    list.setGroupIndicator(null);
    list.setChildIndicator(null);
    list.setOnGroupClickListener(c);
    list.setOnChildClickListener(c);
    list.setAdapter(c.adapter);

    this.registerForContextMenu(list);
}
 
源代码26 项目: FireFiles   文件: 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;
                }
            }
        }
    }
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_explist);

	list = (ExpandableListView) findViewById(android.R.id.list);
	
	listHandler = new ItemExpListHandler(list);
	
	ArrayList<MenuItemDesc> menuItems = fillMenu();
	
	listAdapter = new ItemExpListAdapter(R.layout.item, menuItems, listHandler);
	fillAdapter();
	list.setAdapter(listAdapter);

	listManager = new ItemExpListManager(this, listHandler, true);
}
 
源代码28 项目: FireFiles   文件: 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;
    }
}
 
源代码29 项目: ans-android-sdk   文件: ViewClickProbe.java
@Override
public void trackExpListViewChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, boolean hasTrackClickAnn,long currentTime) {
    try {

        if (isTrackClickSwitchClose()) {
            return;
        }

        Object pageObj = AllegroUtils.getPageObjFromView(parent);
        if (!checkTrackClickEnable(pageObj, v, hasTrackClickAnn) || !checkTrackClickEnable(pageObj, parent, hasTrackClickAnn)) {
            return;
        }

        Map<String, Object> viewInfo = new HashMap<>();
        String[] viewTypeAndText = AllegroUtils.getViewTypeAndText(v);
        String viewType = "ExpandableListViewChildItem:" + viewTypeAndText[0];
        viewInfo.put(Constants.ELEMENT_TYPE, viewType);
        viewInfo.put(Constants.ELEMENT_CONTENT, viewTypeAndText[1]);
        viewInfo.put(Constants.ELEMENT_POSITION, groupPosition + ":" + childPosition);

        String idName = AllegroUtils.getViewIdResourceName(v);
        if (!TextUtils.isEmpty(idName)) {
            viewInfo.put(Constants.ELEMENT_ID, idName);
        }

        autoTrackClick(pageObj, viewInfo, hasTrackClickAnn,currentTime);
    } catch (Throwable ignore) {
        ExceptionUtil.exceptionThrow(ignore);
    }
}
 
源代码30 项目: ans-android-sdk   文件: ViewClickProbe.java
@Override
public void trackExpListViewGroupClick(ExpandableListView parent, View v, int groupPosition, boolean hasTrackClickAnn,long currentTime) {
    try {
        if (isTrackClickSwitchClose()) {
            return;
        }

        Object pageObj = AllegroUtils.getPageObjFromView(parent);
        if (!checkTrackClickEnable(pageObj, v, hasTrackClickAnn) || !checkTrackClickEnable(pageObj, parent, hasTrackClickAnn)) {
            return;
        }

        Map<String, Object> viewInfo = new HashMap<>();
        String[] viewTypeAndText = AllegroUtils.getViewTypeAndText(v);
        String viewType = "ExpandableListViewGroupItem:" + viewTypeAndText[0];
        viewInfo.put(Constants.ELEMENT_TYPE, viewType);
        viewInfo.put(Constants.ELEMENT_CONTENT, viewTypeAndText[1]);
        viewInfo.put(Constants.ELEMENT_POSITION, groupPosition);

        String idName = AllegroUtils.getViewIdResourceName(v);
        if (!TextUtils.isEmpty(idName)) {
            viewInfo.put(Constants.ELEMENT_ID, idName);
        }

        trackListView(parent, v, groupPosition, hasTrackClickAnn,currentTime);
    } catch (Throwable ignore) {
        ExceptionUtil.exceptionThrow(ignore);
    }
}
 
 类所在包
 同包方法