List of usage examples for android.widget ExpandableListView setAdapter
public void setAdapter(ExpandableListAdapter adapter)
From source file:com.ymt.demo1.plates.hub.FireHubMainFragment.java
protected void initView(View view) { //??/*from w ww.j av a2 s. c o m*/ ExpandableListView expandableListView = (ExpandableListView) view.findViewById(R.id.hub_list_view); //? ProgressBar progressBar = new ProgressBar(getActivity()); progressBar.setIndeterminate(true); expandableListView.setEmptyView(progressBar); hubPlateAdapter = new HubPlateAdapter(getActivity()); expandableListView.setAdapter(hubPlateAdapter); //item expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { //??? Intent intent = new Intent(getActivity(), SubjectsActivity.class); intent.putExtra("plate", childList.get(groupPosition).get(childPosition)); intent.putExtra("group_name", parentList.get(groupPosition).getName()); startActivity(intent); getActivity().overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); return true; } }); ImageView doPostView = (ImageView) view.findViewById(R.id.hub_act_post); // ImageView topPostView = (ImageView) view.findViewById(R.id.hub_act_top); ImageView newPostView = (ImageView) view.findViewById(R.id.hub_act_new); ImageView hotPostView = (ImageView) view.findViewById(R.id.hub_act_hot); ImageView myPostView = (ImageView) view.findViewById(R.id.hub_act_my); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.hub_act_post: //? Intent intent1 = new Intent(getActivity(), DoPostActivity.class); ArrayList<HubPlate> parents = new ArrayList<>(); for (HubPlate plate : parentList) { parents.add(plate); } ArrayList<HubPlate> childs = new ArrayList<>(); for (List<HubPlate> pList : childList) { for (HubPlate plate : pList) { childs.add(plate); } } intent1.putParcelableArrayListExtra("parent", parents); intent1.putParcelableArrayListExtra("child", childs); getActivity().startActivity(intent1); getActivity().overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); break; // case R.id.hub_act_top: //?? // // break; case R.id.hub_act_new: //? Intent intentN = new Intent(getActivity(), HotNewPostActivity.class); intentN.putExtra("type", HotNewPostActivity.TYPE_NEW); startActivity(intentN); getActivity().overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); break; case R.id.hub_act_hot: //? Intent intentH = new Intent(getActivity(), HotNewPostActivity.class); intentH.putExtra("type", HotNewPostActivity.TYPE_HOT); startActivity(intentH); getActivity().overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); break; case R.id.hub_act_my: //? startActivity(new Intent(getActivity(), MyHubTabActivity.class)); getActivity().overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); break; } } }; doPostView.setOnClickListener(onClickListener); // topPostView.setOnClickListener(onClickListener); newPostView.setOnClickListener(onClickListener); hotPostView.setOnClickListener(onClickListener); myPostView.setOnClickListener(onClickListener); }
From source file:com.robandjen.comicsapp.FullscreenActivity.java
boolean setComicsXml(InputStream is) { try {/*from www. j av a 2 s .c o m*/ XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser parser = factory.newPullParser(); parser.setInput(new BufferedInputStream(is), null); mComicList = ComicsParser.parse(parser); } catch (Exception e) { return false; } //Reset to beginning mCurComic = 0; if (mComicList != null) { ExpandableListView elv = (ExpandableListView) findViewById(R.id.comic_drawer); mAdapter = new ExpandableComicListAdapter(this, mComicList); elv.setAdapter(mAdapter); elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { mCurComic = mAdapter.childToComicsPos(groupPosition, childPosition); showCurrentComic(); mDrawerLayout.closeDrawers(); return true; } }); } return true; }
From source file:com.utils.widget.head.HeaderFragment.java
public void setListViewAdapter(ExpandableListView listView, BaseExpandableListAdapter adapter) { isListViewEmpty = adapter == null;//from ww w . ja v a 2 s .co m // listView.setAdapter(null); listView.removeHeaderView(mFakeHeader); listView.addHeaderView(mFakeHeader); listView.setAdapter(adapter); }
From source file:com.jbirdvegas.mgerrit.PatchSetViewerFragment.java
private void init() { View currentFragment = this.getView(); ExpandableListView mListView = (ExpandableListView) currentFragment.findViewById(R.id.commit_cards); disconnectedView = currentFragment.findViewById(R.id.disconnected_view); sIsLegacyVersion = !Config.isDiffSupported(mParent); mAdapter = new CommitDetailsAdapter(mParent); mListView.setAdapter(mAdapter); // Child click listeners (relevant for the changes cards) mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mFilesCAB = new FilesCAB(mParent, !sIsLegacyVersion); mAdapter.setContextualActionBar(mFilesCAB); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override/*from ww w . j a v a2 s .com*/ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ExpandableListView listView = (ExpandableListView) parent; long pos = listView.getExpandableListPosition(position); int groupPos = ExpandableListView.getPackedPositionGroup(pos); int childPos = ExpandableListView.getPackedPositionChild(pos); if (!mAdapter.isLongClickSupported(groupPos, childPos)) { return false; } // In case this is a group view and does not have the change number tagged view.setTag(R.id.changeID, mSelectedChange); FilesCAB.TagHolder holder = new FilesCAB.TagHolder(view, mContext, groupPos, childPos >= 0); // Set the title to be shown in the action bar if (holder.filePath != null) { mFilesCAB.setTitle(holder.filePath); } else { String s = mParent.getResources().getString(R.string.change_detail_heading); mFilesCAB.setTitle(String.format(s, holder.changeNumber.intValue())); } mFilesCAB.setActionMode(getActivity().startActionMode(mFilesCAB)); ActionMode actionMode = mFilesCAB.getActionMode(); // Call requires API 14 (ICS) actionMode.setTag(holder); view.setSelected(true); return true; } }); mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // This is only valid for the changed files group int childItemType = mAdapter.getChildType(groupPosition, childPosition); if (childItemType != CommitDetailsAdapter.Cards.CHANGED_FILES.ordinal()) { return false; } // View the diff and close the CAB if a change diff could be viewed boolean diffLaunched = PatchSetChangesCard.onViewClicked(mParent, v); if (diffLaunched) { ActionMode mode = mFilesCAB.getActionMode(); if (mode != null) mode.finish(); } return diffLaunched; } }); mUrl = new GerritURL(); Button retryButton = (Button) currentFragment.findViewById(R.id.btn_retry); retryButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (sIsLegacyVersion) sendRequest(GerritService.DataType.Commit); else sendRequest(GerritService.DataType.LegacyCommitDetails); } }); if (getArguments() == null) { /** This should be the default value of {@link ChangeListFragment.mSelectedStatus } */ setStatus(JSONCommit.Status.NEW.toString()); loadChange(true); } else { Bundle args = getArguments(); setStatus(args.getString(STATUS)); String changeid = args.getString(CHANGE_ID); mChangeNumber = args.getInt(CHANGE_NO); if (changeid != null && !changeid.isEmpty()) { loadChange(changeid); } } mEventBus = EventBus.getDefault(); }
From source file:com.fitme.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.options, menu); MenuItem mi = menu.findItem(R.id.menu_spinner_active_program); final TextView tv = (TextView) mi.getActionView(); ActiveProgramDAO apd = new ActiveProgramDAO(MainActivity.this); activeProgram = apd.getActiveProgramName(); tv.setText(activeProgram);/* w w w . j a v a2 s .c o m*/ tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(MainActivity.this); dialog.setTitle(getText(R.string.title_select_prog_dialog)); View programView = getLayoutInflater().inflate(R.layout.programs_list, null); ExpandableListView elv = (ExpandableListView) programView.findViewById(R.id.list_programs); final ProgramListAdapter pda = new ProgramListAdapter(MainActivity.this); elv.setAdapter(pda); // Setting listener for Add Program button Button addProgram = (Button) programView.findViewById(R.id.button_add_program); addProgram.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { onAddProgramRequested(pda); } }); elv.setGroupIndicator(null); elv.setOnGroupClickListener(null); elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) { pda.setProgramSelected(groupPosition, childPosition); onNewProgramSelected(pda.getSelectedProgramName()); // Refresh trainings section list TrainingsSectionFragment tsf = (TrainingsSectionFragment) mAppSectionsPagerAdapter .getItem(AppSectionsPagerAdapter.SECTION_TRAININGS); tsf.onNewProgramSelected(); dialog.dismiss(); return false; } }); dialog.setContentView(programView); dialog.show(); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); } }); return true; }
From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.audio_browser, container, false); mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.content); mFlingViewGroup.setOnViewSwitchedListener(mViewSwitchListener); mHeader = (HorizontalScrollView) v.findViewById(R.id.header); mHeader.setOnTouchListener(new OnTouchListener() { @Override/* ww w . j a v a2 s . com*/ public boolean onTouch(View v, MotionEvent e) { // prevent the user from scrolling the header return true; } }); ListView songsList = (ListView) v.findViewById(R.id.songs_list); ExpandableListView artistList = (ExpandableListView) v.findViewById(R.id.artists_list); ExpandableListView albumList = (ExpandableListView) v.findViewById(R.id.albums_list); ExpandableListView genreList = (ExpandableListView) v.findViewById(R.id.genres_list); songsList.setAdapter(mSongsAdapter); artistList.setAdapter(mArtistsAdapter); albumList.setAdapter(mAlbumsAdapter); genreList.setAdapter(mGenresAdapter); songsList.setOnItemClickListener(songListener); artistList.setOnGroupClickListener(playlistListener); albumList.setOnGroupClickListener(playlistListener); genreList.setOnGroupClickListener(playlistListener); artistList.setOnChildClickListener(playlistChildListener); albumList.setOnChildClickListener(playlistChildListener); genreList.setOnChildClickListener(playlistChildListener); registerForContextMenu(songsList); registerForContextMenu(artistList); registerForContextMenu(albumList); registerForContextMenu(genreList); return v; }
From source file:nl.atcomputing.refcard.fragments.RegExpFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.listview); // obtain the basic and extended regexp_array regexpb = getResources().getStringArray(R.array.regexpb_array); regexpe = getResources().getStringArray(R.array.regexpe_array); regexpp = getResources().getStringArray(R.array.regexpp_array); // define and activate the expandable list adapter SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(), createGroupList(), R.layout.regroups, new String[] { "reCategory" }, new int[] { R.id.recategory }, createChildList(), R.layout.rerow, new String[] { "resym", "redesc" }, new int[] { R.id.resymbol, R.id.retext }); lv.setAdapter(expListAdapter); }
From source file:nl.atcomputing.refcard.fragments.ViFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ExpandableListView lv = (ExpandableListView) getView().findViewById(R.id.listview); // obtain the arrays with the subcommands per category visubcmdm = getResources().getStringArray(R.array.visubcomm_array); visubcmdi = getResources().getStringArray(R.array.visubcomi_array); visubcmde = getResources().getStringArray(R.array.visubcome_array); visubcmdf = getResources().getStringArray(R.array.visubcomf_array); // define and activate the expandable list adapter SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(), createGroupList(), R.layout.vigroups, new String[] { "viCategory" }, new int[] { R.id.vicategory }, createChildList(), R.layout.virow, new String[] { "viSubCom", "viSubText" }, new int[] { R.id.visubcom, R.id.visubtext }); lv.setAdapter(expListAdapter); }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.JustificationsAll.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.justification_against, container, false); // Create Expandable List and set it's properties ExpandableListView expandableList = (ExpandableListView) v .findViewById(R.id.justification_against_expandablelist); expandableList.setDividerHeight(2);//from w w w . j ava 2 s . c o m expandableList.setGroupIndicator(null); expandableList.setClickable(true); // Set the Items of Parent setGroupParents(); // Set The Child Data setChildData(); // Create the Adapter MyExpandableAdapter adapter = new MyExpandableAdapter(parentItems, childItems); adapter.setInflater((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE), getActivity()); // Set the Adapter to expandableList expandableList.setAdapter(adapter); /* expandableList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { return false; } });*/ return v; }
From source file:org.messic.android.activities.fragments.PlaylistFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_playlist, container, false); getMessicService();// w w w .j av a 2 s . com ExpandableListView gv = (ExpandableListView) rootView.findViewById(R.id.playlist_elistview); if (sa == null) { sa = new PlaylistAdapter(getActivity(), new SongAdapter.EventListener() { public void textTouch(MDMSong song, int index) { AlbumController.getAlbumInfo(PlaylistFragment.this.getActivity(), song.getAlbum().getSid()); } public void coverTouch(MDMSong song, int index) { musicSrv.getPlayer().addSong(song); Toast.makeText(getActivity(), getResources().getText(R.string.player_added) + song.getName(), Toast.LENGTH_SHORT).show(); } public void coverLongTouch(MDMSong song, int index) { musicSrv.getPlayer().addAndPlay(song); } public void elementRemove(MDMSong song, int index) { // TODO Auto-generated method stub } public void playlistTouch(MDMPlaylist playlist, int index) { musicSrv.getPlayer().addPlaylist(playlist); Toast.makeText(getActivity(), getResources().getText(R.string.player_added) + playlist.getName(), Toast.LENGTH_SHORT) .show(); } }); } gv.setAdapter(sa); final SwipeRefreshLayout srl = (SwipeRefreshLayout) rootView.findViewById(R.id.playlist_swipe); // sets the colors used in the refresh animation srl.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN); srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { public void onRefresh() { new Handler().post(new Runnable() { public void run() { getActivity().findViewById(R.id.playlist_progress).setVisibility(View.VISIBLE); controller.getPlaylistMusic(sa, getActivity(), PlaylistFragment.this, true, srl); } }); } }); return rootView; }