List of usage examples for android.widget ExpandableListView expandGroup
public boolean expandGroup(int groupPos)
From source file:org.xbmc.kore.ui.TVShowEpisodeListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); seasonsEpisodesListView.setEmptyView(emptyView); seasonsEpisodesListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override//from www.j a v a 2s .c o m public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (parent.isGroupExpanded(groupPosition)) { parent.collapseGroup(groupPosition); groupsExpanded.remove(groupPosition); } else { parent.expandGroup(groupPosition); groupsExpanded.put(groupPosition, true); } return true; } }); seasonsEpisodesListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // Get the movie id from the tag EpisodeViewHolder tag = (EpisodeViewHolder) v.getTag(); // Notify the activity listenerActivity.onEpisodeSelected(tvshowId, tag.episodeId); return true; } }); setHasOptionsMenu(true); if (savedInstanceState != null) { listPosition = savedInstanceState.getInt(BUNDLE_SAVEDINSTANCE_LISTPOSITION, 0); itemPosition = savedInstanceState.getInt(BUNDLE_SAVEDINSTANCE_ITEMPOSITION, 0); groupsExpanded = (HashMap) savedInstanceState.getSerializable(BUNDLE_SAVEDINSTANCE_GROUPSEXPANDED); isReturning = true; } initLoader(); }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); Intent homeIntent = new Intent(); homeIntent.setClassName("com.android.launcher", "com.android.launcher.Launcher"); menu.add("Default home").setIcon(R.drawable.ic_menu_home).setIntent(homeIntent); menu.add("Search").setIcon(android.R.drawable.ic_menu_search); force = menu.add("Expand all").setIcon(android.R.drawable.ic_menu_share) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { ExpandableListView listView = LauncherActivity.this.getExpandableListView(); ExpandableListAdapter adapter = LauncherActivity.this.getExpandableListAdapter(); switch (expandState) { case STATE_UNKNOWN: case STATE_ALL_COLLAP: // when unknown or collapsed, we force all open for (int i = 0; i < adapter.getGroupCount(); i++) listView.expandGroup(i); expandState = STATE_ALL_EXPAND; break; case STATE_ALL_EXPAND: // when expanded, we force all closed for (int i = 0; i < adapter.getGroupCount(); i++) listView.collapseGroup(i); expandState = STATE_ALL_COLLAP; break; }/*from ww w .j av a 2 s . com*/ return true; } }); menu.add("Refresh").setIcon(R.drawable.ic_menu_refresh) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // clear any database mappings and local json cache // TODO: clear local json cache (when implemented) appdb.deleteAllMappings(); setListAdapter(null); new ProcessTask().execute(); return true; } }); Intent settingsIntent = new Intent(android.provider.Settings.ACTION_SETTINGS); settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); menu.add("Settings").setIcon(android.R.drawable.ic_menu_preferences).setIntent(settingsIntent); return true; }
From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java
private void selectGroup(ExpandableListView parent, int groupPosition, boolean simulateChildClick) { QueryType queryType = null;/*w w w . j ava 2s .co m*/ String subTitle = null; switch (groupPosition) { case DrawerListAdapter.ALL_GROUP: // selected all group item queryType = new QueryType(QueryMode.All); subTitle = (String) mDrawerAdapter.getGroup(groupPosition); break; case DrawerListAdapter.FAVORITES_GROUP: // selected favorite group item queryType = new QueryType(QueryMode.Favorites); subTitle = (String) mDrawerAdapter.getGroup(groupPosition); break; case DrawerListAdapter.CITIES_GROUP: case DrawerListAdapter.ROUTES_GROUP: // selected routes group item if (parent.isGroupExpanded(groupPosition)) { parent.collapseGroup(groupPosition); } else { parent.expandGroup(groupPosition); } setCurrentGroup(groupPosition); if (simulateChildClick) { selectCamera(getCurrentChild()); } break; case DrawerListAdapter.NEAR_ME_GROUP: // selected favorite group item queryType = new QueryType(QueryMode.NearMe); subTitle = (String) mDrawerAdapter.getGroup(groupPosition); break; } if (queryType != null) { mFragment.getCameras(queryType); mDrawerLayout.closeDrawer(mDrawerList); mActionBar.setSubtitle(subTitle); setCurrentGroup(groupPosition); } }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
public T expand(int position, boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; if (expand) { elv.expandGroup(position); } else {//from w w w . j ava 2 s. c om elv.collapseGroup(position); } } return self(); }
From source file:com.huishen.edrive.center.CoachMealListFragment.java
public void setList(String data, ExpandableListView list) { if (loading.getVisibility() == View.VISIBLE) { loading.setVisibility(View.GONE); }/* ww w .j a va 2s. c om*/ // mGroupData = new ArrayList<HashMap<String, String>>(); mData = new ArrayList<ArrayList<String>>(); try { //[{"carTypeContent":"","cash":50,"cohId":1,"content":"?", // "createDate":"2015-03-01","id":1,"schoolId":1,"title":"","type":2}, // {"carTypeContent":"?","cash":50,"cohId":1,"content":"??","createDate":"2015-03-18", // "id":2,"schoolId":1,"title":"?","type":2}] JSONArray array = new JSONArray(data); for (int i = 0; i < array.length(); i++) { JSONObject json = array.getJSONObject(i); HashMap<String, String> map = new HashMap<String, String>(); map.put("mealname", json.optString(SRL.ReturnField.COACH_MEAL_TITLE, "")); map.put("mealprize", json.optString(SRL.ReturnField.COACH_MEAL_PRIZE, "")); mGroupData.add(map); ArrayList<String> childmap = new ArrayList<String>(); childmap.add("???" + json.optString(SRL.ReturnField.COACH_MEAL_CONTENT, "")); childmap.add("" + json.optString(SRL.ReturnField.COACH_MEAL_CARTYPE, "")); childmap.add("? " + json.optString(SRL.ReturnField.COACH_MEAL_CLASSTYPE, "")); childmap.add("" + json.optString(SRL.ReturnField.COACH_MEAL_LICENSETYPE, "")); mData.add(childmap); } CoachMealListExpandAdapter judgeAdapter = new CoachMealListExpandAdapter(this.getActivity(), mGroupData, mData); list.setAdapter(judgeAdapter); if (mGroupData.size() > 0) { list.expandGroup(0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
public T expand(boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; ExpandableListAdapter ela = elv.getExpandableListAdapter(); if (ela != null) { int count = ela.getGroupCount(); for (int i = 0; i < count; i++) { if (expand) { elv.expandGroup(i); } else { elv.collapseGroup(i); }/*from ww w.j a v a 2 s . com*/ } } } return self(); }
From source file:biz.bokhorst.xprivacy.ActivityApp.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final int userId = Util.getUserId(Process.myUid()); // Check privacy service client if (!PrivacyService.checkClient()) return;//from w w w . j ava2 s.co m // Set layout setContentView(R.layout.restrictionlist); // Get arguments Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } int uid = extras.getInt(cUid); String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null); String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null); // Get app info mAppInfo = new ApplicationInfoEx(this, uid); if (mAppInfo.getPackageName().size() == 0) { finish(); return; } // Set title setTitle(String.format("%s - %s", getString(R.string.app_name), TextUtils.join(", ", mAppInfo.getApplicationName()))); // Handle info click ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo); imgInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Packages can be selected on the web site Util.viewUri(ActivityApp.this, Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s", mAppInfo.getPackageName().get(0)))); } }); // Display app name TextView tvAppName = (TextView) findViewById(R.id.tvApp); tvAppName.setText(mAppInfo.toString()); // Background color if (mAppInfo.isSystem()) { LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo); llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous))); } // Display app icon final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon); imgIcon.setImageDrawable(mAppInfo.getIcon(this)); // Handle icon click imgIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openContextMenu(imgIcon); } }); // Display on-demand state final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand); if (PrivacyManager.isApplication(mAppInfo.getUid()) && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) { boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); imgCbOnDemand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, Boolean.toString(ondemand)); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); } }); } else imgCbOnDemand.setVisibility(View.GONE); // Display restriction state swEnabled = (Switch) findViewById(R.id.swEnable); swEnabled.setChecked( PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true)); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, Boolean.toString(isChecked)); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); imgCbOnDemand.setEnabled(isChecked); } }); imgCbOnDemand.setEnabled(swEnabled.isChecked()); // Add context menu to icon registerForContextMenu(imgIcon); // Check if internet access if (!mAppInfo.hasInternet(this)) { ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet); imgInternet.setVisibility(View.INVISIBLE); } // Check if frozen if (!mAppInfo.isFrozen(this)) { ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen); imgFrozen.setVisibility(View.INVISIBLE); } // Display version TextView tvVersion = (TextView) findViewById(R.id.tvVersion); tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this))); // Display package name TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName); tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName())); // Fill privacy list view adapter final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction); lvRestriction.setGroupIndicator(null); mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName, methodName); lvRestriction.setAdapter(mPrivacyListAdapter); if (restrictionName != null) { int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values()) .indexOf(restrictionName); lvRestriction.expandGroup(groupPosition); lvRestriction.setSelectedGroup(groupPosition); if (methodName != null) { int childPosition = PrivacyManager.getHooks(restrictionName) .indexOf(new Hook(restrictionName, methodName)); lvRestriction.setSelectedChild(groupPosition, childPosition, true); } } // Listen for package add/remove IntentFilter iff = new IntentFilter(); iff.addAction(Intent.ACTION_PACKAGE_REMOVED); iff.addDataScheme("package"); registerReceiver(mPackageChangeReceiver, iff); mPackageChangeReceiverRegistered = true; // Up navigation getActionBar().setDisplayHomeAsUpEnabled(true); // Tutorial if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) { ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); } View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { ViewParent parent = view.getParent(); while (!parent.getClass().equals(ScrollView.class)) parent = parent.getParent(); ((View) parent).setVisibility(View.GONE); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString()); } }; ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener); ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener); // Process actions if (extras.containsKey(cAction)) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(mAppInfo.getUid()); if (extras.getInt(cAction) == cActionClear) optionClear(); else if (extras.getInt(cAction) == cActionSettings) optionSettings(); } // Annotate Meta.annotate(this); }
From source file:com.androidquery.AQuery.java
public AQuery expand(int position, boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; if (expand) { elv.expandGroup(position); } else {//from w ww .j a va 2 s. c o m elv.collapseGroup(position); } } return self(); }
From source file:com.androidquery.AbstractAQuery.java
public T expand(int position, boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; if (expand) { elv.expandGroup(position);//from w ww . j a va2 s .c o m } else { elv.collapseGroup(position); } } return self(); }
From source file:com.androidquery.AQuery.java
public AQuery expand(boolean expand) { if (view instanceof ExpandableListView) { ExpandableListView elv = (ExpandableListView) view; ExpandableListAdapter ela = elv.getExpandableListAdapter(); if (ela != null) { int count = ela.getGroupCount(); for (int i = 0; i < count; i++) { if (expand) { elv.expandGroup(i); } else { elv.collapseGroup(i); }// w ww.j a v a2 s . com } } } return self(); }