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

The following examples show how to use android.widget.ExpandableListView#expandGroup() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * 
 * 点击了 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 Project: ActivityLauncher   File: AllTasksListAdapter.java    License: 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
@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 Project: test-samples   File: DI_DeviceInfo.java    License: 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
@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 Project: letv   File: ChannelDetailListAdapter.java    License: 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 7
Source Project: letv   File: StarRankAdapter.java    License: 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 8
Source Project: FireFiles   File: RootsFragment.java    License: 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 9
Source Project: FireFiles   File: RootsFragment.java    License: 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 10
Source Project: FireFiles   File: RootsFragment.java    License: 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 11
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 12
@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 13
@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 14
@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 15
@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 16
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 17
Source Project: flow-android   File: CourseUtil.java    License: 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);
    }
}