Java Code Examples for android.widget.ExpandableListView#expandGroup()

The following examples show how to use android.widget.ExpandableListView#expandGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IphoneTreeView.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * 点击了 Group 触发的事件 , 要根据根据当前点击 Group 的状态来
 */
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
		int groupPosition, long id) {
	if (mAdapter.getHeadViewClickStatus(groupPosition) == 0) {
		mAdapter.onHeadViewClick(groupPosition, 1);
		parent.expandGroup(groupPosition);
		parent.setSelectedGroup(groupPosition);

	} else if (mAdapter.getHeadViewClickStatus(groupPosition) == 1) {
		mAdapter.onHeadViewClick(groupPosition, 0);
		parent.collapseGroup(groupPosition);
	}

	// 返回 true 才可以弹回第一行 , 不知道为什么
	return true;

}
 
Example 2
Source File: AllTasksListAdapter.java    From ActivityLauncher with ISC License 6 votes vote down vote up
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    MyPackageInfo pack = (MyPackageInfo) getGroup(groupPosition);
    View view = this.inflater.inflate(R.layout.all_activities_group_item, null);

    TextView text = view.findViewById(android.R.id.text1);
    text.setText(pack.getName());

    ImageView icon = view.findViewById(android.R.id.icon);
    icon.setImageDrawable(pack.getIcon());

    // expand if filtered list is short enough
    if (filtered.size() < 10) {
        ExpandableListView expandableListView = (ExpandableListView) parent;
        expandableListView.expandGroup(groupPosition);
    }

    return view;
}
 
Example 3
Source File: ResultsActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.results_expandablelistview);

  Gson gson = new Gson();

  LinkedHashMap<String, List<String>> groupedStatistics = gson
      .fromJson(results, new ResultsActivity.LinkedHashMapTypeToken().getType());

  // create expandable list view
  ExpandableListView expandableListView = findViewById(R.id.expandableListView);
  ExpandableListAdapter expandableListAdapter = new ExpandableListViewAdapter(this, groupedStatistics);
  expandableListView.setAdapter(expandableListAdapter);
  // expand the first group by default
  expandableListView.expandGroup(0);
}
 
Example 4
Source File: DI_DeviceInfo.java    From test-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.di_layout);

    propertyGroupList = new ArrayList<DevicePropertyGroup>();

    elv_deviceInfo = (ExpandableListView) findViewById(R.id.di_elv_deviceInfo);

    collectPropertiesBuild();
    collectPropertiesBattery();
    collectPropertiesHardware();
    collectPropertiesSensors();
    collectPropertiesMeasurements();

    DevicePropertyExpandableArrayAdapter expandableArrayAdapter = new DevicePropertyExpandableArrayAdapter(getApplicationContext(), propertyGroupList);
    elv_deviceInfo.setAdapter(expandableArrayAdapter);

    for (int i = 0; i < propertyGroupList.size(); i++) {
        elv_deviceInfo.expandGroup(i, false);
    }

}
 
Example 5
Source File: AboutActivity.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.about);

    LayoutUtils.maximizeWindow(getWindow());

    String name = getResources().getString(R.string.app_name);
    String version = "";
    try {
        final PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        version = packageInfo.versionName;
        name = getResources().getString(packageInfo.applicationInfo.labelRes);
    } catch (final NameNotFoundException e) {
        e.printStackTrace();
    }

    final TextView title = (TextView) findViewById(R.id.about_title);
    title.setText(name + (LengthUtils.isNotEmpty(version) ? " v" + version : ""));

    final ExpandableListView view = (ExpandableListView) findViewById(R.id.about_parts);
    view.setAdapter(new PartsAdapter());
    view.expandGroup(0);
}
 
Example 6
Source File: GenericChannelsFragment.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
private void expandAll(View view) {
	ExpandableListView listView = (ExpandableListView) view.findViewById(
			R.id.channelListView);
	int count = adapter.getGroupCount();
	for (int position = 0; position < count; position++) {
		listView.expandGroup(position);
	}
}
 
Example 7
Source File: ChannelDetailListAdapter.java    From letv with Apache License 2.0 5 votes vote down vote up
public void setList(ExpandableListView listView, ArrayList<AlbumInfo> list) {
    if (list != null && listView != null) {
        this.mList.clear();
        this.mList.addAll(list);
        notifyDataSetChanged();
        for (int i = 0; i < getGroupCount(); i++) {
            listView.expandGroup(i);
        }
        listView.setGroupIndicator(null);
    }
}
 
Example 8
Source File: GenericChannelAdapter.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
           View convertView, ViewGroup viewGroup) {
	String channelGroup = (String) getGroup(groupPosition);
	View returningView = ChannelAdapterHelper.createChannelGroupItem(
			viewGroup.getContext(), convertView, viewGroup, channelGroup);
	
	ExpandableListView listView = (ExpandableListView) viewGroup;
    listView.expandGroup(groupPosition);

	return returningView;
}
 
Example 9
Source File: TheSimpleExpandableListAdapter.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); 
    ExpandableListView eLV = (ExpandableListView) parent; 
    eLV.expandGroup(groupPosition); 
    return v; 
}
 
Example 10
Source File: TheSimpleExpandableListAdapter.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); 
    ExpandableListView eLV = (ExpandableListView) parent; 
    eLV.expandGroup(groupPosition); 
    return v; 
}
 
Example 11
Source File: TheSimpleExpandableListAdapter.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); 
    ExpandableListView eLV = (ExpandableListView) parent; 
    eLV.expandGroup(groupPosition); 
    return v; 
}
 
Example 12
Source File: AccessPointsAdapterGroup.java    From WiFiAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
void update(@NonNull List<WiFiDetail> wiFiDetails, ExpandableListView expandableListView) {
    updateGroupBy();
    if (isGroupExpandable() && expandableListView != null) {
        int groupCount = expandableListView.getExpandableListAdapter().getGroupCount();
        for (int i = 0; i < groupCount; i++) {
            WiFiDetail wiFiDetail = getWiFiDetail(wiFiDetails, i);
            if (expanded.contains(getGroupExpandKey(wiFiDetail))) {
                expandableListView.expandGroup(i);
            } else {
                expandableListView.collapseGroup(i);
            }
        }
    }
}
 
Example 13
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 14
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 15
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 16
Source File: StarRankAdapter.java    From letv with Apache License 2.0 5 votes vote down vote up
public void setList(ExpandableListView listView, List<LTStarRankModelDetailPB> list) {
    if (list != null && listView != null) {
        this.mList.clear();
        this.mList.addAll(list);
        notifyDataSetChanged();
        for (int i = 0; i < getGroupCount(); i++) {
            listView.expandGroup(i);
        }
        listView.setGroupIndicator(null);
    }
}
 
Example 17
Source File: CourseUtil.java    From flow-android with MIT License 4 votes vote down vote up
/**
 * Expands all groups in an ExpandableListView
 * @param listView ExpandableListView to expand
 */
public static void expandAllGroups(ExpandableListView listView) {
    for (int i = 0; i < listView.getExpandableListAdapter().getGroupCount(); i++) {
        listView.expandGroup(i);
    }
}