List of usage examples for android.widget ListView setSelector
public void setSelector(@DrawableRes int resID)
From source file:drawnzer.anurag.archivereaddemo.TarFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub final ListView lsView = (ListView) view.findViewById(R.id.ls); lsView.setSelector(R.drawable.button_click); lsView.setAdapter(new FileAdapter(getActivity(), new File(path).listFiles())); lsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w.ja v a 2 s. c o m public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub if (opened) { //zip file already opened.... //we are selecting sub files inside of zip file.... //getting selected entry from list view.... TarObj obj = (TarObj) lsView.getAdapter().getItem(arg2); //getting path of selected folder inside zip archive.... tar_path = obj.getPath(); if (obj.isFile()) { // a files is selected inside of archive.... Toast.makeText(getActivity(), "A file is selected....", Toast.LENGTH_SHORT).show(); } else { //a folder is selected inside zip archive.... //so further listing the selected folder.... if (tar_path.startsWith("/")) tar_path = tar_path.substring(1, tar_path.length()); try { lsView.setAdapter(read_tar.getAdapter(tar_path, getActivity())); } catch (ZipException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(getActivity(), "Something went wrong....", Toast.LENGTH_SHORT).show(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(getActivity(), "Something went wrong....", Toast.LENGTH_SHORT).show(); } } return; } //folder or some file is selected.... //getting the file.... File getFile = (File) lsView.getAdapter().getItem(arg2); if (getFile.isDirectory()) { //updating th path.... path = path + "/" + getFile.getName(); //updating the listview as per new path.... lsView.setAdapter(new FileAdapter(getActivity(), new File(path).listFiles())); } else { //file is selected.... if (getFile.getName().endsWith(".tar") || getFile.getName().endsWith(".tar.bz2")) { //open the zip file.... opened = true; read_tar = new ReadArchive(getFile); if (tar_path == null) tar_path = "/"; try { lsView.setAdapter(read_tar.getAdapter(tar_path, getActivity())); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(getActivity(), "Invalid tar file....", Toast.LENGTH_SHORT).show(); } } else Toast.makeText(getActivity(), "Choose a tar file to open....", Toast.LENGTH_SHORT).show(); } } }); lsView.setOnItemLongClickListener(null); }
From source file:com.uwetrottmann.movies.ui.MovieDetailsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // set list adapter mAdapter = new MovieSummaryAdapter(getSherlockActivity(), getFragmentManager()); setListAdapter(mAdapter);/* www .ja v a 2s . c om*/ // style list view final ListView list = getListView(); list.setDivider(null); list.setSelector(R.color.transparent); // nag about no connectivity if (!AndroidUtils.isNetworkConnected(getActivity())) { setEmptyText(getString(R.string.offline)); setListShown(true); } else { setEmptyText(getString(R.string.details_empty)); setListShown(false); getLoaderManager().initLoader(MOVIE_LOADER_ID, getArguments(), this); } }
From source file:qr.cloud.qrpedia.MyTagsListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // configure the list view ListView listView = getListView(); QRCloudUtils.setListViewEmptyView(listView, getString(R.string.no_posted_messages), R.string.default_font, R.dimen.activity_horizontal_margin, R.dimen.activity_vertical_margin); listView.setSelector(R.drawable.message_row_selector); // override the default selector listView.setDivider(new ColorDrawable(this.getResources().getColor(R.color.list_divider))); listView.setDividerHeight(1);//from w w w.j a v a 2 s . c om if (mIsInDialog && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // fix black background issue pre-honeycomb listView.setBackgroundColor(Color.WHITE); } }
From source file:qr.cloud.qrpedia.BookmarksListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // configure the list view ListView listView = getListView(); QRCloudUtils.setListViewEmptyView(listView, getString(R.string.no_bookmarks), R.string.default_font, R.dimen.activity_horizontal_margin, R.dimen.activity_vertical_margin); listView.setSelector(R.drawable.message_row_selector); // override the default selector listView.setDivider(new ColorDrawable(this.getResources().getColor(R.color.list_divider))); listView.setDividerHeight(1);//from w w w. j av a 2s. c o m if (mIsInDialog && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // fix black background issue pre-honeycomb listView.setBackgroundColor(Color.WHITE); } }
From source file:qr.cloud.qrpedia.SavedTextListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // configure the list view ListView listView = getListView(); QRCloudUtils.setListViewEmptyView(listView, getString(R.string.no_saved_messages), R.string.default_font, R.dimen.activity_horizontal_margin, R.dimen.activity_vertical_margin); listView.setSelector(R.drawable.message_row_selector); // override the default selector listView.setDivider(new ColorDrawable(this.getResources().getColor(R.color.list_divider))); listView.setDividerHeight(1);/*w w w .j av a2 s . co m*/ listView.setOnItemLongClickListener(mLongClickListener); if (mIsInDialog && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // fix black background issue pre-honeycomb listView.setBackgroundColor(Color.WHITE); } }
From source file:com.github.mobile.gauges.ui.TrafficListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (gauge != null && gaugeId == null) gaugeId = gauge.getId();/* w w w .j ava 2 s .co m*/ ListView listView = getListView(); if (getListAdapter() == null) { listView.addHeaderView(getLayoutInflater(savedInstanceState).inflate(layout.traffic_graph, null), null, false); listView.addHeaderView( getLayoutInflater(savedInstanceState).inflate(layout.traffic_list_item_labels, null), null, false); } listView.setSelector(android.R.color.transparent); listView.setCacheColorHint(getResources().getColor(android.R.color.transparent)); listView.setDrawSelectorOnTop(false); listView.setFastScrollEnabled(true); listView.setDividerHeight(0); }
From source file:org.tanrabad.team.ChatFragment.java
private void turnOffListViewDecoration(ListView listView) { listView.setDivider(null);//from ww w. ja v a 2s . co m listView.setDividerHeight(0); listView.setHorizontalFadingEdgeEnabled(false); listView.setVerticalFadingEdgeEnabled(false); listView.setHorizontalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(true); listView.setSelector(new ColorDrawable(0x00ffffff)); listView.setCacheColorHint(0x00000000); // For Gingerbread scrolling bug fix }
From source file:eu.geopaparazzi.library.forms.FormListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); List<String> fragmentTitles = mFragmentListSupporter.getListTitles(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1, fragmentTitles.toArray(new String[fragmentTitles.size()])); int color = Compat.getColor(getActivity(), R.color.formcolor); int[] colors = { 0, color, 0 }; ListView listView = getListView(); listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); listView.setDividerHeight(2);//w ww.j ava 2 s .co m listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setFocusableInTouchMode(true); StateListDrawable selector = new StateListDrawable(); selector.addState(new int[] { -android.R.attr.state_pressed }, new ColorDrawable(Compat.getColor(getContext(), R.color.main_selection))); listView.setSelector(selector); setListAdapter(adapter); if (fragmentTitles.size() > 0) listView.setItemChecked(0, true); }
From source file:com.google.android.apps.iosched.ui.MyScheduleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container, false);// w w w.jav a 2 s .c o m inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true); root.setBackgroundColor(Color.WHITE); ListView listView = (ListView) root.findViewById(android.R.id.list); listView.setItemsCanFocus(true); listView.setCacheColorHint(Color.WHITE); listView.setSelector(android.R.color.transparent); //listView.setEmptyView(root.findViewById(android.R.id.empty)); return root; }
From source file:com.github.jvanhie.discogsscrobbler.NowPlayingFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setSelection(final ListView list) { list.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); list.setSelector(R.drawable.track_selector); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w .j av a 2s.c o m public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (mBound) { //fully stop previous playlist since we start again from the beginning of the selected track ArrayList<Track> trackList = new ArrayList<Track>(mService.trackList); mService.stop(); mService.trackList = trackList; mService.currentTrack = i; mService.resume(); } } }); list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode actionMode, int i, long l, boolean b) { } @Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.now_playing_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { SparseBooleanArray checkedItems = list.getCheckedItemPositions(); final List<Integer> positions = new ArrayList<Integer>(); if (checkedItems != null) { for (int i = 0; i < checkedItems.size(); i++) { if (checkedItems.valueAt(i)) { positions.add(checkedItems.keyAt(i)); } } } switch (menuItem.getItemId()) { case R.id.play_selection: if (mBound) { //change tracklist and start over again ArrayList<Track> newTrackList = new ArrayList<Track>(); for (Integer i : positions) { newTrackList.add(mService.trackList.get(i)); } //fully stop previous playlist since we start again from the beginning mService.stop(); mService.trackList = newTrackList; mService.currentTrack = 0; mService.resume(); } actionMode.finish(); break; case R.id.remove_selection: int currPlaying = mService.currentTrack; int newPlaying = -1; //change tracklist and start over again ArrayList<Track> newTrackList = new ArrayList<Track>(); for (int i = 0; i < mService.trackList.size(); i++) { if (!positions.contains(i)) { newTrackList.add(mService.trackList.get(i)); } //calculate new currently playing counter if (i == currPlaying) { if (positions.contains(i)) { currPlaying++; } else { newPlaying = newTrackList.size() - 1; } } } //the currently playing track was removed, start fresh from the next available if (currPlaying != mService.currentTrack) { mService.stop(); if (newPlaying != -1) { mService.trackList = newTrackList; mService.currentTrack = newPlaying; mService.resume(); } } else { //pause the playlist and resume with the new tracklist mService.pause(); mService.trackList = newTrackList; mService.currentTrack = newPlaying; mService.resume(); } actionMode.finish(); break; } return false; } @Override public void onDestroyActionMode(ActionMode actionMode) { } }); }