List of usage examples for android.view View setSelected
public void setSelected(boolean selected)
From source file:com.hdezninirola.fantasywithdrawer.custom_views.PagerSlidingTabStrip.java
private void updateActivateTab(final int position) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextColor(position == i ? tabTextColor : tabDeactivateTextColor); } else {// www. java2 s . co m v.setSelected(position == i ? true : false); ((ImageButton) v).setColorFilter(position == i ? tabTextColor : tabDeactivateTextColor); } } }
From source file:com.resonos.apps.library.tabviewpager.TabPageIndicator.java
/** * Method to set the current item that cannot be overridden * @param item/*w w w . j a v a 2s . c o m*/ */ private final void setCurrentItemImpl(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); } mSelectedTabIndex = item; final int tabCount = mTabLayout.getChildCount(); View lastVisibleChild = null; int lastVisibleItem = -1; for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); if (child.getVisibility() == View.VISIBLE) { lastVisibleChild = child; lastVisibleItem = i; } final boolean isSelected = (i == item); if (lastVisibleChild != null) { if (lastVisibleItem == i || isSelected) { lastVisibleChild.setSelected(isSelected); if (isSelected) animateToTab(lastVisibleItem); } } } }
From source file:com.cube.storm.ui.view.PagerSlidingTabStrip.java
private void updateActivateTab(final int position) { for (int i = 0; i < tabCount; i++) { android.view.View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextColor(position == i ? tabTextColor : tabDeactivateTextColor); } else {/*from w w w . j a va 2 s . c o m*/ v.setSelected(position == i ? true : false); } } }
From source file:com.example.fragmentdemo.views.PagerSlidingTabStrip.java
@Override public void setCurrentItem(int item) { if (pager == null) { throw new IllegalStateException("ViewPager has not been bound."); }// w w w . j a va 2 s . c o m selectedPosition = item; pager.setCurrentItem(item); final int tabCount = tabsContainer.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = tabsContainer.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); // if (isSelected) { // animateToTab(item); // } } }
From source file:com.cnm.cnmrc.fragment.vodtvch.VodTvch.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.vod_tvch, container, false); mSlidingMenu = (SlidingMenu) layout.findViewById(R.id.animation_layout); mSlidingMenu.setListener(this); mLoadingData = (FrameLayout) layout.findViewById(R.id.loading_data_panel); mCategoryCover = (FrameLayout) layout.findViewById(R.id.category_cover); mCategoryCover.setOnClickListener(this); mCategoryCover.setVisibility(View.GONE); mCategory = (ListView) layout.findViewById(R.id.category_list); // FragmentManager fm = getActivity().getSupportFragmentManager(); // fm.addOnBackStackChangedListener(mAddOnBackStackChangedListener); // fm.removeOnBackStackChangedListener(mRemoveOnBackStackChangedListener); // -------------------------- // type check (vod or tvch) // -------------------------- String type = getArguments().getString("type"); if (type.equals("vod")) { mCategoryArray = getActivity().getResources().getStringArray(R.array.vod_category); mClassTypeArray = getActivity().getResources().getStringArray(R.array.vod_class_type); }//www.j av a 2s . c om if (type.equals("tvch")) { mCategoryArray = getActivity().getResources().getStringArray(R.array.tvch_category); mClassTypeArray = getActivity().getResources().getStringArray(R.array.tvch_class_type); } ArrayList<String> arrayList = new ArrayList<String>(mCategoryArray.length); for (String item : mCategoryArray) { arrayList.add(item); } // ------------------------- // set title : category // ------------------------- // ?? , ? back key . depth . mMapTitle = new HashMap<Integer, String>(); setTitle(0); // ------------------- // sidebar category // ------------------- VodTvchAdapter adapter = new VodTvchAdapter(getActivity(), R.layout.list_item_vod_category, arrayList); mCategory.setAdapter(adapter); mCategory.setDivider(null); mCategory.setDividerHeight(0); mCategory.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // sidebar return... ? sidebar ?? ??... if (!mSlidingMenu.isOpening()) return; // sidebar ? item?? ... mCategoryCover.setVisibility(View.VISIBLE); // change category text color view.setSelected(true); selectedCategory = position; // change title setTitle(position); // close sidebar mSlidingMenu.toggleSidebar(); Log.i("hwang", "category is selected"); /*View v; int count = parent.getChildCount(); v = parent.getChildAt(position);*/ } }); // ----------------------- // ? bottom menu // ----------------------- Fragment f = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_rc_bottom_menu); if (f != null) ((RcBottomMenu) f).setVodTvchMode(); // -------------------------------------------------------------------------------------------------------- // ? ? ? fragment VodTvch ?? loadingDataForSidrebar()? no addToBackStack ??. // -------------------------------------------------------------------------------------------------------- loadingDataForSidrebar(); return layout; }
From source file:com.kindleren.kandouwo.common.views.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/*from w ww . jav a2 s . co m*/ } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); //change alpha if (indicatorDrawable != null) { ((TextView) currentTab) .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5)))); } currentTab.setSelected(true); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); float lineTop = currentTab.getTop(); float lineBottom = currentTab.getBottom(); // if there is an offset, start interpolating left and right coordinates between current and next tab if (currentPositionOffset >= 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); //change alpha if (indicatorDrawable != null) { ((TextView) nextTab) .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5)))); } final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); //change view state if (currentPositionOffset > 0.5) { currentTab.setSelected(false); nextTab.setSelected(true); } else { currentTab.setSelected(true); nextTab.setSelected(false); } } rectPaint.setColor(underlineColor); if (indicatorDrawable != null) { indicatorDrawable.setBounds((int) lineLeft + getPaddingLeft(), (int) lineTop + getPaddingTop(), (int) lineRight + getPaddingLeft(), (int) lineBottom + getPaddingTop()); indicatorDrawable.draw(canvas); } else { canvas.drawRect(lineLeft + 30, height - indicatorHeight, lineRight - 30, height, rectPaint); } canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.justinbull.ichnaeachecker.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w ww . j av a 2s .c om*/ setCellInfo(); mCellListView = (ListView) findViewById(R.id.cellListView); mCellListView.setAdapter(mCellListAdapter); mCellListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mCellListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { GeneralCellInfo cell = (GeneralCellInfo) parent.getItemAtPosition(position); if (!cell.isFullyKnown()) { Snackbar snack = Snackbar.make(view, "Not enough information known about selected cell", Snackbar.LENGTH_SHORT); snack.getView() .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorError)); snack.show(); return; } mSelectedCell = cell; view.setSelected(true); Snackbar.make(view, "Selected " + mSelectedCell.getCellType() + " Cell " + mSelectedCell.getFriendlyCellIdentity(), Snackbar.LENGTH_SHORT).show(); } }); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); assert fab != null; fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED) { setCellInfo(); } if (mSelectedCell == null) { Toast.makeText(MainActivity.this, "Choose a cell to check", Toast.LENGTH_SHORT).show(); return; } final Snackbar snack = Snackbar.make(view, "Checking Mozilla Location Services database...", Snackbar.LENGTH_INDEFINITE); snack.show(); try { final RequestHandle handler = getIchnaeaLookup(snack); assert handler != null; snack.setAction("CANCEL", new View.OnClickListener() { @Override public void onClick(View view) { snack.setText("Cancelling lookup request..."); if (!handler.isFinished()) { handler.cancel(true); } else { snack.setText("Request already finished!"); snack.setDuration(Snackbar.LENGTH_LONG); snack.show(); } } }).show(); } catch (IllegalArgumentException e) { Log.w(TAG, "onClick: ", e); snack.setDuration(Snackbar.LENGTH_SHORT); snack.setText("Not enough information known about selected cell"); snack.show(); } } }); }
From source file:com.yahala.ui.Views.PagerSlidingTabStrip.java
private void updateActivateTab(final int position) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextColor(position == i ? tabTextColor : tabDeactivateTextColor); } else {//from ww w .java 2s. c om IconButton tab = (IconButton) v; tab.setTextColor(position == i ? tabTextColor : tabDeactivateTextColor); v.setSelected(position == i ? true : false); } } }
From source file:com.uoit.freeroomfinder.RoomsBooked.java
/** * SetupUpTableView Sets up the logic for handling what happens inside the table of booking * entries.// ww w . j ava 2 s . c o m * * @param inflater The specified inflater for the view. * @param container The ViewGroup container for the view. * @param index The index of the selected row. * * @return Returns the corresponding table row that was selected. */ public TableRow SetupUpTableView(LayoutInflater inflater, ViewGroup container, final int index) { // Get all the handles to the UI elements inside the view. View newView = inflater.inflate(R.layout.room_book_item, container, false); TextView room = (TextView) newView.findViewById(R.id.book_room); TextView start = (TextView) newView.findViewById(R.id.book_stime); TextView end = (TextView) newView.findViewById(R.id.book_etime); TextView date = (TextView) newView.findViewById(R.id.book_date); // Get the index of the result. Rooms first = results.get(index); // Get the attributes of this booking. room.setText(first.getRoom()); start.setText(DateTimeUtility.formatTime(new Date(first.getStartTime()))); end.setText(DateTimeUtility.formatTime(new Date(first.getEndTime()))); date.setText(DateTimeUtility.formatDate(first.getDate())); TableRow tr = (TableRow) newView.findViewById(R.id.tableRow2); tr.setOnLongClickListener(new View.OnLongClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnLongClickListener#onLongClick(android.view.View) */ public boolean onLongClick(View view) { // Called when the user long-clicks on a View. if (mActionMode != null) { return false; } // Set the row as highlighted. selectedRow = (TableRow) view; background = selectedRow.getBackground(); selectedRow.setBackgroundColor( RoomsBooked.this.getResources().getColor(android.R.color.holo_blue_light)); rowIndex = index; // Start the CAB using the ActionMode. Callback defined above. mActionMode = getActivity().startActionMode(mActionModeCallback); view.setSelected(true); return true; } }); this.registerForContextMenu(tr); return tr; }
From source file:com.oldfeel.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null;/* ww w . ja v a2s . com*/ if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (i == 0) { tabView.setSelected(true); } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }