List of usage examples for android.widget RelativeLayout getChildAt
public View getChildAt(int index)
From source file:Main.java
public static void animateIn(View view) { if (view instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) view; for (int i = 0; i < relativeLayout.getChildCount(); i++) { View child = relativeLayout.getChildAt(i); child.animate().setStartDelay(100 + i * DELAY).alpha(1).scaleX(1).scaleY(1); }/*from w w w . ja v a 2 s . c o m*/ } else { LinearLayout linearLayout = (LinearLayout) view; for (int i = 0; i < linearLayout.getChildCount(); i++) { View child = linearLayout.getChildAt(i); child.animate().setStartDelay(100 + i * DELAY).alpha(1).scaleX(1).scaleY(1); } } }
From source file:Main.java
public static void animateOut(View view) { if (view instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) view; for (int i = 0; i < relativeLayout.getChildCount(); i++) { View child = relativeLayout.getChildAt(i); child.animate().setStartDelay(i).alpha(0).scaleX(0f).scaleY(0f); }/* w w w . ja v a2s. c o m*/ } else { LinearLayout linearLayout = (LinearLayout) view; for (int i = 0; i < linearLayout.getChildCount(); i++) { View child = linearLayout.getChildAt(i); child.animate().setStartDelay(i).alpha(0).scaleX(0f).scaleY(0f); } } }
From source file:sysnetlab.android.sdc.test.TestHelper.java
public static void selectSensors(ActivityInstrumentationTestCase2<?> testCase, Activity activity) { Assert.assertTrue("The activity must be a CreateExperimentActivity.", activity instanceof CreateExperimentActivity); // choose to select sensors CreateExperimentActivity createExperimentActivity = (CreateExperimentActivity) activity; Fragment fragment = createExperimentActivity.getSupportFragmentManager() .findFragmentById(R.id.fragment_container); Assert.assertNotNull("The ExperimentSetupFragment should not be null.", fragment); Assert.assertTrue("The fragment should be an ExperimentSetupFragment.", fragment instanceof ExperimentSetupFragment); ListView listViewOperations = (ListView) fragment.getView().findViewById(R.id.lv_operations); Assert.assertNotNull("The operations ListView should not be null.", listViewOperations); Assert.assertEquals("The operations ListView should has 3 items", listViewOperations.getCount(), 3); TouchUtils.clickView(testCase, listViewOperations.getChildAt(2)); testCase.getInstrumentation().waitForIdleSync(); // select the 1st sensor fragment = createExperimentActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container); Assert.assertNotNull("The ExperimentSensorSelectionFragment should not be null.", fragment); Assert.assertTrue("The fragment should be an ExperimentSensorListFragment.", fragment instanceof ExperimentSensorSelectionFragment); RelativeLayout layout = (RelativeLayout) fragment.getView().findViewById(R.id.layout_sensor_selection_list); Assert.assertNotNull("The Sensor ListView should not be null.", layout); ListView sensorListView = null; for (int i = 0; i < layout.getChildCount(); i++) { View child = layout.getChildAt(i); if (child instanceof ListView) sensorListView = (ListView) child; }//from w w w .j a v a2s .c o m Assert.assertNotNull("The Sensor ListView should not be null", sensorListView); int numberOfSensorsToSelect = (int) (Math.random() * sensorListView.getCount()) + 1; int numberOfSensorsSelected = 0; int sensorPosition = 0; while (numberOfSensorsSelected < numberOfSensorsToSelect) { double rn = Math.random(); if ((sensorListView.getCount() - sensorPosition) * rn >= numberOfSensorsToSelect - numberOfSensorsSelected) { sensorPosition++; } else { TouchUtils.clickView(testCase, sensorListView.getChildAt(sensorPosition).findViewById(R.id.check)); sensorPosition++; numberOfSensorsSelected++; } } testCase.getInstrumentation().waitForIdleSync(); }
From source file:br.unisinos.evertonlucas.passshelter.app.SendResourceGroupActivity.java
public void btnSendResource(View view) { try {/* w w w. j av a2 s . c o m*/ this.progressDialog = ProgressDialogUtil.createProgressDialog(this, getString(R.string.process_send_resource)); RelativeLayout parent = (RelativeLayout) view.getParent(); TextView txtSendResource = (TextView) parent.getChildAt(0); Group group = this.groupsRep.getGroupByName(txtSendResource.getText().toString()); new SendProcessGroupAsyncTask(this, service, resourceRep, this, parseData, localUserRep, group) .execute(resourceName); } catch (Exception e) { this.progressDialog.dismiss(); ShowLogExceptionUtil.showAndLogException(this, "Erro ao enviar recurso", e); } }
From source file:br.unisinos.evertonlucas.passshelter.app.UsersNewGroupActivity.java
public void btnClearUserGroup(View view) { RelativeLayout layout = (RelativeLayout) view.getParent(); TextView txtUserGroup = (TextView) layout.getChildAt(0); ParseUser user = null;//from w ww. j a v a2s .co m for (ParseUser userList : emailUsersGroup) { if (userList.getEmail().trim().equals(txtUserGroup.getText().toString())) user = userList; } if (user != null) { emailUsersGroup.remove(user); refreshListAdapter(); } }
From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java
private View handleTrains(final int position, View convertView, @NonNull final ViewGroup parent) { // Train/* w w w. j a v a 2 s. c o m*/ final Station station = stations.get(position); final Set<TrainLine> trainLines = station.getLines(); TrainViewHolder viewHolder; if (convertView == null || convertView.getTag() == null) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_nearby, parent, false); viewHolder = new TrainViewHolder(); viewHolder.resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results); viewHolder.stationNameView = (TextView) convertView.findViewById(R.id.station_name); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.icon); viewHolder.details = new HashMap<>(); viewHolder.arrivalTime = new HashMap<>(); convertView.setTag(viewHolder); } else { viewHolder = (TrainViewHolder) convertView.getTag(); } viewHolder.stationNameView.setText(station.getName()); viewHolder.imageView .setImageDrawable(ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_train_white_24dp)); for (final TrainLine trainLine : trainLines) { if (trainArrivals.indexOfKey(station.getId()) != -1) { final List<Eta> etas = trainArrivals.get(station.getId()).getEtas(trainLine); if (etas.size() != 0) { final LinearLayout llv; boolean cleanBeforeAdd = false; if (viewHolder.details.containsKey(trainLine)) { llv = viewHolder.details.get(trainLine); cleanBeforeAdd = true; } else { final LinearLayout llh = new LinearLayout(context); llh.setOrientation(LinearLayout.HORIZONTAL); llh.setPadding(line1PaddingColor, stopsPaddingTop, 0, 0); llv = new LinearLayout(context); llv.setOrientation(LinearLayout.VERTICAL); llv.setPadding(line1PaddingColor, 0, 0, 0); llh.addView(llv); viewHolder.resultLayout.addView(llh); viewHolder.details.put(trainLine, llv); } final List<String> keysCleaned = new ArrayList<>(); for (final Eta eta : etas) { final Stop stop = eta.getStop(); final String key = station.getName() + "_" + trainLine.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(); if (viewHolder.arrivalTime.containsKey(key)) { final RelativeLayout insideLayout = viewHolder.arrivalTime.get(key); final TextView timing = (TextView) insideLayout.getChildAt(2); if (cleanBeforeAdd && !keysCleaned.contains(key)) { timing.setText(""); keysCleaned.add(key); } final String timingText = timing.getText() + eta.getTimeLeftDueDelay() + " "; timing.setText(timingText); } else { final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout insideLayout = new RelativeLayout(context); insideLayout.setLayoutParams(leftParam); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams availableParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableParam.addRule(RelativeLayout.RIGHT_OF, lineId); availableParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final TextView stopName = new TextView(context); final String destName = eta.getDestName() + ": "; stopName.setText(destName); stopName.setTextColor(ContextCompat.getColor(parent.getContext(), R.color.grey_5)); stopName.setLayoutParams(availableParam); int availableId = Util.generateViewId(); stopName.setId(availableId); final RelativeLayout.LayoutParams availableValueParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableValueParam.addRule(RelativeLayout.RIGHT_OF, availableId); availableValueParam.setMargins(0, 0, 0, 0); final TextView timing = new TextView(context); final String timeLeftDueDelay = eta.getTimeLeftDueDelay() + " "; timing.setText(timeLeftDueDelay); timing.setTextColor(ContextCompat.getColor(parent.getContext(), R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); timing.setLayoutParams(availableValueParam); insideLayout.addView(lineIndication); insideLayout.addView(stopName); insideLayout.addView(timing); llv.addView(insideLayout); viewHolder.arrivalTime.put(key, insideLayout); } } } } } convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, station.getId(), station.getStopsPosition().get(0).getLatitude(), station.getStopsPosition().get(0).getLongitude())); return convertView; }
From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java
public void setCenterView(TiViewProxy viewProxy) { if (viewProxy == null || viewProxy == this.centerView) { return;/*from www. j a v a 2 s.com*/ } viewProxy.setActivity(proxy.getActivity()); TiUIView contentView = viewProxy.getOrCreateView(); View view = contentView.getOuterView(); RelativeLayout container = (RelativeLayout) layout.findViewById(id_drawer_layout_container); TiCompositeLayout content = (TiCompositeLayout) container.getChildAt(1); ViewParent viewParent = view.getParent(); if (viewParent != null && viewParent != content && viewParent instanceof ViewGroup) { ((ViewGroup) viewParent).removeView(view); } content.addView(view, contentView.getLayoutParams()); if (this.centerView != null) { content.removeView(this.centerView.getOrCreateView().getNativeView()); } this.centerView = viewProxy; }
From source file:com.cloud.widget.viewpager.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { RelativeLayout rl = (RelativeLayout) tabsContainer.getChildAt(i); View v = rl.getChildAt(0); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextAppearance(getContext(), tabDefaultTextAppearance); if (pager != null && i == pager.getCurrentItem()) { tab.setTextAppearance(getContext(), tabSelectedTextAppearance); }/*from w w w . j a va 2 s.co m*/ // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(titleText.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.collcloud.frame.viewpager.PagerSlidingTabStrip.java
public void updateTabStyles(int curPosition) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof RelativeLayout) { RelativeLayout rL = (RelativeLayout) v; TextView tab = (TextView) rL.getChildAt(0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (curPosition == i) { tab.setTextColor(pstsTextHighLightColor); } else { tab.setTextColor(tabTextColor); }/*from ww w .j a v a2 s. c o m*/ // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { RelativeLayout tabLayout = (RelativeLayout) tabsContainer.getChildAt(i); View v = tabLayout.getChildAt(0); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); //// w w w .j a v a2 s . c om // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build // if (textAllCaps) { // if (Build.VERSION.SDK_INT >= // Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // tab.setAllCaps(true); // } else { // tab.setText(tab.getText().toString().toUpperCase(locale)); // } // } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } } }