List of usage examples for android.view ViewGroup getChildAt
public View getChildAt(int index)
From source file:me.xiaopan.psts.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (allowWidthFull && tabsLayout != null) { View childView;//w w w . j ava 2s . c o m for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { childView = tabsLayout.getChildAt(w); ViewGroup.LayoutParams params = childView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; childView.setLayoutParams(params); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return; } ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null) { return; } if (tabsLayout.getChildCount() <= 0) { return; } if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:cz.tsystems.portablecheckin.MainActivity.java
private void populateTextsAndRbtn(ViewGroup theView) { String fieldName = ""; DMCheckin checkinData = app.getCheckin(); for (int i = 0; i < theView.getChildCount(); i++) { View v = theView.getChildAt(i); Class<? extends View> c = v.getClass(); fieldName = (String) v.getTag(); if (fieldName == null) continue; Field field = null;/*from ww w. j a va 2 s .c o m*/ try { field = DMCheckin.class.getField(fieldName.toLowerCase(Locale.ENGLISH)); } catch (NoSuchFieldException e) { Log.v(TAG, "NOT FOUND :" + fieldName.toLowerCase(Locale.ENGLISH)); continue; } Log.v(TAG, fieldName.toLowerCase(Locale.ENGLISH)); try { if (c == EditText.class || c == vinEditText.class || c == BaseEditText.class) { EditText editText = (EditText) v; editText.setText(""); if (field.get(checkinData) == null) continue; DecimalFormat nf = new DecimalFormat("#"); if (field.getType() == String.class)// jnCheckin.hasNonNull(fieldName)) editText.setText((String) field.get(checkinData)); else if (field.getType() == int.class) editText.setText(String.valueOf(field.getInt(checkinData))); else if (field.getType() == short.class) editText.setText(String.valueOf(field.getShort(checkinData))); else if (field.getType() == double.class) editText.setText(nf.format(field.getDouble(checkinData))); else if (field.getType() == Double.class) editText.setText(NumberFormat.getInstance().format((Double) field.get(checkinData))); else if (field.getType() == Date.class) editText.setText(sdto.format((Date) field.get(checkinData))); } else if (c == Switch.class) { ((Switch) v).setChecked(field.getBoolean(checkinData)); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:biz.laenger.android.vpbs.ViewPagerBottomSheetBehavior.java
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; }/* ww w. j ava 2 s. c om*/ if (view instanceof ViewPager) { ViewPager viewPager = (ViewPager) view; View currentViewPagerChild = ViewPagerUtils.getCurrentView(viewPager); View scrollingChild = findScrollingChild(currentViewPagerChild); if (scrollingChild != null) { return scrollingChild; } } else if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
From source file:com.cjj.viewpagerlibrary.PagerSlidingTabStrip.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); ViewGroup tabViewGroup = getTabsLayout(); if (tabViewGroup != null) { // ?????// ww w .j a v a 2 s . co m currentPosition = viewPager != null ? viewPager.getCurrentItem() : 0; if (!disableViewPager) { scrollToChild(currentPosition, 0); //?? selectedTab(currentPosition); //?TAB } //?tab?Pager for (int w = 0; w < tabViewGroup.getChildCount(); w++) { View itemView = tabViewGroup.getChildAt(w); itemView.setTag(w); itemView.setOnClickListener(this); } } }
From source file:biz.laenger.android.vpbs.ViewPagerBottomSheetBehavior.java
private View findAllScrollableChild(View view) { if (view instanceof NestedScrollingChild) { return view; }/*w w w.ja v a 2 s .c o m*/ if (view instanceof ViewPager) { ViewPager viewPager = ((ViewPager) view); for (int c = 0; c < viewPager.getChildCount(); c++) { View currentViewPagerChild = viewPager.getChildAt(c); if (currentViewPagerChild != null) { View scrollingChild = findAllScrollableChild(currentViewPagerChild); if (scrollingChild != null) { scrollableViews.add(new WeakReference<View>(scrollingChild)); } } } } else if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findAllScrollableChild(group.getChildAt(i)); if (scrollingChild != null) { scrollableViews.add(new WeakReference<>(scrollingChild)); } } } return null; }
From source file:com.gome.haoyuangong.views.SwipeRefreshLayout.java
private boolean canChildScroll(ViewGroup group, int direction, int startindex) { boolean canScroll = false; if (mCurrentTargetOffsetTop != 0) { return false; }// w w w . j av a 2s . c o m int count = group.getChildCount(); for (int i = startindex; i < count; i++) { View child = group.getChildAt(i); if (child instanceof LinearLayout || child instanceof RelativeLayout) { canScroll = canChildScroll((ViewGroup) child, direction, 0); } else { canScroll = canScroll(child, direction); return canScroll; } } return canScroll; }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { final CharSequence displayContents = resultHandler.getDisplayContents(); // if (copyToClipboard && !resultHandler.areContentsSecure()) { // ClipboardInterface.setText(displayContents, this); // }/* ww w. j ava2s .c o m*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // if (resultHandler.getDefaultButtonID() != null && prefs.getBoolean(PreferencesActivity.KEY_AUTO_OPEN_WEB, false)) { // resultHandler.handleButtonPress(resultHandler.getDefaultButtonID()); // return; // } statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view); if (barcode == null) { barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)); } else { barcodeImageView.setImageBitmap(barcode); } TextView formatTextView = (TextView) findViewById(R.id.format_text_view); formatTextView.setText(rawResult.getBarcodeFormat().toString()); TextView typeTextView = (TextView) findViewById(R.id.type_text_view); typeTextView.setText(resultHandler.getType().toString()); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); TextView timeTextView = (TextView) findViewById(R.id.time_text_view); timeTextView.setText(formatter.format(new Date(rawResult.getTimestamp()))); TextView metaTextView = (TextView) findViewById(R.id.meta_text_view); View metaTextViewLabel = findViewById(R.id.meta_text_view_label); metaTextView.setVisibility(View.GONE); metaTextViewLabel.setVisibility(View.GONE); Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata(); if (metadata != null) { StringBuilder metadataText = new StringBuilder(20); for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) { if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) { metadataText.append(entry.getValue()).append('\n'); } } if (metadataText.length() > 0) { metadataText.setLength(metadataText.length() - 1); metaTextView.setText(metadataText); metaTextView.setVisibility(View.VISIBLE); metaTextViewLabel.setVisibility(View.VISIBLE); } } final TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view); final String baseUrl = "http://qrk.kuaipai.cn/loganal/base/scan/show-json-advert.action?code="; new Thread(new Runnable() { @Override public void run() { HttpGet get = new HttpGet(baseUrl + displayContents); Log.e(TAG, "full url = " + baseUrl + displayContents); HttpClient client = new DefaultHttpClient(); try { HttpResponse response = client.execute(get); String json = EntityUtils.toString(response.getEntity(), "UTF-8"); JSONObject jsonObject = new JSONObject(json); NetScanResult result = new NetScanResult(); result.name = jsonObject.getString("name"); result.url = jsonObject.getString("img"); Message message = new Message(); message.obj = result; message.what = 1; mNetHandler.sendMessage(message); } catch (Exception e) { mNetHandler.sendEmptyMessage(-1); e.printStackTrace(); } } }).start(); // contentsTextView.setText(displayContents); int scaledSize = Math.max(22, 32 - displayContents.length() / 4); contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view); supplementTextView.setText(""); supplementTextView.setOnClickListener(null); // if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean( // PreferencesActivity.KEY_SUPPLEMENTAL, true)) { // SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, // resultHandler.getResult(), // historyManager, // this); // } int buttonCount = resultHandler.getButtonCount(); ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view); buttonView.requestFocus(); for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) { TextView button = (TextView) buttonView.getChildAt(x); if (x < buttonCount) { button.setVisibility(View.VISIBLE); button.setText(resultHandler.getButtonText(x)); button.setOnClickListener(new ResultButtonListener(resultHandler, x)); } else { button.setVisibility(View.GONE); } } }
From source file:com.juick.android.MainActivity.java
public static void visitViewHierarchy(View view, ViewHierarchyVisitor visitor) { visitor.visitView(view);/*from w w w . j a v a 2 s .co m*/ if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; int childCount = group.getChildCount(); for (int i = 0; i < childCount; i++) { visitViewHierarchy(group.getChildAt(i), visitor); } } }
From source file:com.nttec.everychan.ui.MainActivity.java
private boolean hasChild(View view, View child) { if (view == child) return true; if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0; i < group.getChildCount(); ++i) { if (hasChild(group.getChildAt(i), child)) return true; }// w ww.j a v a 2 s . c o m } return false; }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); ViewGroup tabViewGroup = getTabsLayout(); if (tabViewGroup != null) { // ?????//from ww w .j a va 2 s.co m currentPosition = viewPager != null ? viewPager.getCurrentItem() : 0; if (!disableViewPager) { scrollToChild(currentPosition, 0); // ?? selectedTab(currentPosition); // ?TAB } // ?tab?Pager for (int w = 0; w < tabViewGroup.getChildCount(); w++) { View itemView = tabViewGroup.getChildAt(w); itemView.setTag(w); itemView.setOnClickListener(this); } } }