List of usage examples for android.view View setSelected
public void setSelected(boolean selected)
From source file:cn.softbank.purchase.widget.pagerindicator.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { return;//ww w. j av a 2 s . com } mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } if (mOnItemClickListener != null) { mOnItemClickListener.itemClick(mSelectedTabIndex); } }
From source file:com.turman.oschina.ui.MainActivity.java
@Override public void onTabChanged(String tabId) { final int size = mTabHost.getTabWidget().getTabCount(); for (int i = 0; i < size; i++) { View v = mTabHost.getTabWidget().getChildAt(i); if (i == mTabHost.getCurrentTab()) { v.setSelected(true); } else {// ww w . java2 s.co m v.setSelected(false); } } // if (tabId.equals(getString(MainTab.ME.getResName()))) { // mBvNotice.setText(""); // mBvNotice.hide(); // } supportInvalidateOptionsMenu(); }
From source file:com.esri.arcgisruntime.sample.transformsbysuitability.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the list of transformations final ListView tableList = findViewById(R.id.transforms_list); mTransformAdapter = new DatumTransformationAdapter(this, mTransformValues); tableList.setAdapter(mTransformAdapter); tableList.setOnItemClickListener((AdapterView<?> adapterView, View view, int i, long l) -> { view.setSelected(true); // Get the datum transformation selected by the user DatumTransformation selectedTransform = (DatumTransformation) adapterView.getAdapter().getItem(i); Point projectedGeometry;/* ww w. j av a2s . c o m*/ try { // Use the selected transformation to reproject the Geometry projectedGeometry = (Point) GeometryEngine.project(mOriginalGeometry, mMapView.getSpatialReference(), selectedTransform); } catch (ArcGISRuntimeException agsEx) { // Catch errors thrown from project method. If a transformation is missing grid files, then it cannot be // successfully used to project a geometry, and will throw an exception. Snackbar.make(tableList, agsEx.getMessage() + "\n" + getResources().getString(R.string.transform_missing_files), Snackbar.LENGTH_LONG).show(); removeProjectedGeometryGraphic(); return; } // Add projected geometry as a second graphic - use a cross symbol which ensures the default transformation // graphic remains visible beneath this graphic. if (mProjectedGraphic == null) { mProjectedGraphic = addGraphic(projectedGeometry, Color.argb(255, 255, 0, 0), SimpleMarkerSymbol.Style.CROSS); } else { // If graphic already set, just update the geometry mProjectedGraphic.setGeometry(projectedGeometry); } }); // If the CheckBox is not checked (default), transformations should be ordered by suitability for the whole // spatial reference. If checked, then transformations will be ordered by suitability for the map extent. CheckBox checkBox = findViewById(R.id.order_by_check_box); checkBox.setOnCheckedChangeListener((CompoundButton compoundButton, boolean newCheckState) -> { // Store the new check state in a member variable and update the list of transformations. mUseExtentForSuitability = newCheckState; setupTransformsList(); }); // Get MapView from layout and set a map into this view mMapView = findViewById(R.id.mapView); mArcGISMap = new ArcGISMap(Basemap.createLightGrayCanvas()); mMapView.setMap(mArcGISMap); // Create a geometry located in the Greenwich observatory courtyard in London, UK, the location of the // Greenwich prime meridian. This will be projected using the selected transformation. mOriginalGeometry = new Point(538985.355, 177329.516, SpatialReference.create(27700)); // Add a Graphic to show the original geometry location, projected using the default transformation addGraphic(mOriginalGeometry, Color.argb(255, 0, 0, 255), SimpleMarkerSymbol.Style.SQUARE); mArcGISMap.addDoneLoadingListener(() -> { if (mArcGISMap.getLoadStatus() == LoadStatus.LOADED) { if (mTransformValues.size() == 0) { // Zoom to the initial default geometry at a suitable scale Viewpoint vp = new Viewpoint(mOriginalGeometry, 5000); mMapView.setViewpointAsync(vp, 2); // Once the map has loaded (which means the 'from' spatial reference is set), trigger populating the list // of transformations. Start by checking app has permissions to access local file storage, where projection // engine files for grid-based transformations are stored. checkPermissions(); } } }); }
From source file:com.zhejunzhu.ucviewpager.weight.StreamTabIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { // throw new IllegalStateException("ViewPager has not been bound."); return;//from w w w . j a v a 2 s . co m } mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } }
From source file:ch.ethz.twimight.activities.DmListActivity.java
/** * Called when the activity is first created. *//*from w ww .j a va 2 s . co m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dm_list); getActionBar().setDisplayHomeAsUpEnabled(true); mUserRowId = getIntent().getIntExtra(EXTRA_KEY_USER_ROW_ID, 0); mScreenname = getIntent().getStringExtra(EXTRA_KEY_SCREEN_NAME); // If we don't know which user to show, we stop the activity if (mUserRowId == 0 || mScreenname == null) { finish(); } setTitle(getString(R.string.direct_messages)); getActionBar().setSubtitle(getString(R.string.with) + " @" + mScreenname); mListView = (ListView) findViewById(R.id.dmUserList); mCursor = getContentResolver().query(Uri.parse("content://" + DirectMessages.DM_AUTHORITY + "/" + DirectMessages.DMS + "/" + DirectMessages.DMS_USER + "/" + mUserRowId), null, null, null, null); mAdapter = new DmAdapter(this, mCursor); mListView.setAdapter(mAdapter); mListView.setEmptyView(findViewById(R.id.dmListEmpty)); mListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { mSelectedPosition = position; mActionMode = startActionMode(DmListActivity.this); view.setSelected(true); return true; } }); }
From source file:cn.ibona.commonutil.indicator.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from w w w.ja v a 2 s .c o m mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); ((TabView) child).setTextColor(getResources().getColor(R.color.vpi__background_holo_light)); int select_icon = 0; if (i == 0) { select_icon = R.drawable.tab_bag_left_select; } else if (i == tabCount - 1) { select_icon = R.drawable.tab_bag_right_select; } else { select_icon = R.drawable.tab_bag_certen_select; } child.setBackgroundResource(select_icon); } else { ((TabView) child).setTextColor(getResources().getColor(R.color.vpi__background_holo_dark)); int unselect_icon = 0; if (i == 0) { unselect_icon = R.drawable.tab_bag_left_unselect; } else if (i == tabCount - 1) { unselect_icon = R.drawable.tab_bag_right_unselect; } else { unselect_icon = R.drawable.tab_bag_certen_unselect; } child.setBackgroundResource(unselect_icon); } } }
From source file:com.lingyang.camera.ui.widget.TabPageIndicator.java
@Override public void setCurrentItem(int item) { // if (mViewPager == null) { // throw new IllegalStateException("ViewPager has not been bound."); // }/* ww w . j av a 2s .c om*/ mSelectedTabIndex = item; if (mViewPager != null) mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); // child.setFocusableInTouchMode(isSelected); // if (i == item) { // child.setBackgroundColor(getResources().getColor(R.color.main_tile)); // } else { // child.setBackgroundColor(getResources().getColor(R.color.main_tile_normal)); // } if (isSelected) { animateToTab(item); } } }
From source file:cn.com.bjnews.thinker.view.MyTabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from ww w .j a v a 2s .c om mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (child instanceof TextView) { if (isSelected) ((TextView) child).setTextColor(selectedColor); else ((TextView) child).setTextColor(Color.WHITE); } if (isSelected) { animateToTab(item); } } }
From source file:com.cflp.zwl.view.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from w ww . ja v a2 s .co m mSelectedTabIndex = item; mViewPager.setCurrentItem(item); TabView view = (TabView) mTabLayout.getChildAt(item); PagerAdapter adapter = mViewPager.getAdapter(); view.setTextColor(Color.parseColor(((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0))); if (((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0).equals("#CC0000")) { view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_meeting); } else if (((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0).equals("#3366ff")) { switch (view.getWidth()) { case 408: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_408); break; case 205: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_205); break; case 164: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_164); break; case 105: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_105); break; case 82: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_82); break; default: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_164); } } final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } }
From source file:com.solo.viewpagernestedfragmentdemo.widget.PagerIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from w w w. j a v a 2s. c om mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); // final int tabCount = getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); // final View child = getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } }