List of usage examples for android.widget LinearLayout getChildCount
public int getChildCount()
From source file:fr.cph.chicago.core.activity.StationActivity.java
public void hideAllArrivalViews() { Stream.of(station.getLines()) .flatMap(trainLine -> Stream.of(TrainDirection.values()) .map(trainDirection -> trainLine.toString() + "_" + trainDirection.toString())) .forEach(key -> {//from www. j a va2s .c o m if (ids.containsKey(key)) { final int id = ids.get(key); final LinearLayout line3View = (LinearLayout) findViewById(id); if (line3View != null) { line3View.setVisibility(View.GONE); if (line3View.getChildCount() > 0) { Stream.range(0, line3View.getChildCount()).forEach(i -> { final LinearLayout view = (LinearLayout) line3View.getChildAt(i); final TextView timing = (TextView) view.getChildAt(1); if (timing != null) { timing.setText(""); } }); } } } }); }
From source file:cn.com.incito.driver.UI.detailDialog.PCCFragmentActivity.java
/** * ??/*ww w .ja v a 2 s. c o m*/ */ private void setSelectedBtnsListener() { LinearLayout selectedLayout = (LinearLayout) findViewById(R.id.selected_cities_linearlayout); for (int i = 0; i < selectedLayout.getChildCount(); i++) { Button selectedBtn = (Button) selectedLayout.getChildAt(i); selectedBtn.setTag(i); selectedBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int indext = (Integer) v.getTag(); selectedCities.remove(indext); notifySelectedCities(); pager.setCurrentItem(0); cityFragment.clearDatas(); countryFragment.clearDatas(); if (selectedCities.size() > 0) { mCurrentSelected = selectedCities.size() - 1; } else { mCurrentSelected = -1; } } }); } }
From source file:com.nadmm.airports.FragmentBase.java
protected View addRow(LinearLayout layout, String label, String value) { if (layout.getChildCount() > 0) { addSeparator(layout);// w w w .j a va 2 s . co m } LinearLayout row = (LinearLayout) inflate(R.layout.detail_row_item2); TextView tv = (TextView) row.findViewById(R.id.item_label); tv.setText(label); tv = (TextView) row.findViewById(R.id.item_value); if (value != null && value.length() > 0) { tv.setText(value); } else { tv.setVisibility(View.GONE); } layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); return row; }
From source file:com.qiscus.sdk.filepicker.util.TabLayoutHelper.java
private int determineTabMode(@NonNull TabLayout tabLayout) { LinearLayout slidingTabStrip = (LinearLayout) tabLayout.getChildAt(0); int childCount = slidingTabStrip.getChildCount(); // NOTE: slidingTabStrip.getMeasuredWidth() method does not return correct width! // Need to measure each tabs and calculate the sum of them. int tabLayoutWidth = tabLayout.getMeasuredWidth() - tabLayout.getPaddingLeft() - tabLayout.getPaddingRight(); int tabLayoutHeight = tabLayout.getMeasuredHeight() - tabLayout.getPaddingTop() - tabLayout.getPaddingBottom(); if (childCount == 0) { return TabLayout.MODE_FIXED; }/* www. java 2 s. c o m*/ int stripWidth = 0; int maxWidthTab = 0; int tabHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(tabLayoutHeight, View.MeasureSpec.EXACTLY); for (int i = 0; i < childCount; i++) { View tabView = slidingTabStrip.getChildAt(i); tabView.measure(View.MeasureSpec.UNSPECIFIED, tabHeightMeasureSpec); int tabWidth = tabView.getMeasuredWidth(); stripWidth += tabWidth; maxWidthTab = Math.max(maxWidthTab, tabWidth); } return ((stripWidth < tabLayoutWidth) && (maxWidthTab < (tabLayoutWidth / childCount))) ? TabLayout.MODE_FIXED : TabLayout.MODE_SCROLLABLE; }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * Recording time ASYNCHRONOUSLY/*from ww w .j av a 2 s. c om*/ * * @param v */ public void onClickRecord(View v) { LinearLayout llTimePicker = (LinearLayout) v.getParent(); LinearLayout lllFrag = (LinearLayout) llTimePicker.getParent(); LinearLayout llTime = (LinearLayout) llTimePicker.findViewById(R.id.llTimePicker); TimePicker tp = (TimePicker) llTime.findViewById(R.id.tpTask); Integer oiHour = tp.getCurrentHour(); Integer oiMin = tp.getCurrentMinute(); DateUtils du = new DateUtils(); long lmills = du.toMills(oiHour, oiMin); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckIn = new Date().getTime(); long lCheckOut = lCheckIn + lmills; // Save data into both databases Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_ASYNCHRONOUS); recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT) .show(); }
From source file:com.narkii.security.info.BaseDataFragment.java
/** * /*w w w . j a va 2 s.c om*/ * @param view view */ private void clearPersonInfoView(View view) { final LinearLayout parent = (LinearLayout) view.getParent().getParent(); Log.d(TAG, "remove person view: " + parent.getChildCount()); if (parent.getChildCount() > 1) { parent.removeViews(1, parent.getChildCount() - 1); } }
From source file:com.todoroo.astrid.activity.TaskEditFragment.java
public static void setViewHeightBasedOnChildren(LinearLayout view) { int totalHeight = 0; int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(), MeasureSpec.AT_MOST); for (int i = 0; i < view.getChildCount(); i++) { View listItem = view.getChildAt(i); listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += listItem.getMeasuredHeight(); }//from w w w .j a va 2 s . c o m ViewGroup.LayoutParams params = view.getLayoutParams(); if (params == null) return; params.height = totalHeight; view.setLayoutParams(params); view.requestLayout(); }
From source file:com.cssweb.android.quote.QHSCGridActivity.java
private void clearData(int scrollNum) { for (int i = 1; i <= scrollNum; i++) { TextView localView6 = (TextView) this.mLinerLock.findViewWithTag(i); TextView localView7 = (TextView) this.mLinerLock2.findViewWithTag(i); localView6.setText(""); localView7.setText(""); LinearLayout localLinearLayout = (LinearLayout) this.mLinerHScroll.findViewWithTag(i); int i6 = localLinearLayout.getChildCount(); for (int j = 0; j < i6; j++) { TextView localView5 = (TextView) localLinearLayout.getChildAt(j); localView5.setText(""); }/*from www . j a va 2 s .c om*/ } }
From source file:com.nadmm.airports.FragmentBase.java
protected View addRow(LinearLayout layout, String label, String value1, String value2) { if (layout.getChildCount() > 0) { addSeparator(layout);/*from w ww . j a va2 s . c o m*/ } LinearLayout row = (LinearLayout) inflate(R.layout.detail_row_item3); TextView tv = (TextView) row.findViewById(R.id.item_label); tv.setText(label); tv = (TextView) row.findViewById(R.id.item_value); if (value1 != null && value1.length() > 0) { tv.setText(value1); } else { tv.setVisibility(View.GONE); } tv = (TextView) row.findViewById(R.id.item_extra_value); if (value2 != null && value2.length() > 0) { tv.setText(value2); } else { tv.setVisibility(View.GONE); } layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); return row; }
From source file:com.materialdesign.view.tab.TabLayout.java
/** * ?tab/*from ww w . j a v a 2s .co m*/ * * @param view tabView * @param selector ? */ private void tabViewSelector(View view, boolean selector) { LinearLayout layout = null; if (LinearLayout.class.isInstance(view)) { layout = (LinearLayout) view; } for (int y = 0; y < layout.getChildCount(); y++) { layout.getChildAt(y).setSelected(selector); } }