List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
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) { // ?????// w w 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:org.cirdles.chroni.FilePickerActivity.java
/** * This method either shows all of the checkboxes on the list items, or adds every file that has been checked off * * @param executeMove a boolean that specifies whether to add the files to the ArrayList or not *//*from ww w . j a v a2 s.co m*/ public void toggleMove(boolean executeMove) { ViewGroup list = getListView(); int number = list.getChildCount(); if (inMovePickMode) { mOptionsMenu.findItem(R.id.deleteFilePickerMenu).setVisible(true); // puts the delete items option back cutFiles = new ArrayList<>(); // initializes cutFiles to add files to // only adds files IF the user has pressed done (executeMove will be true) if (executeMove) { // gets rid of all of the move checkboxes and add files to cutFiles for (int i = 0; i < number; i++) { View child = list.getChildAt(i); CheckBox checkbox = (CheckBox) child.findViewById(R.id.checkBoxFilePicker); // adds the file to cutFiles IF the checkbox is checked if (checkbox.isChecked()) { File fileToCut = mAdapter.getItem(i); cutFiles.add(fileToCut); // un-checks the checkbox checkbox.setChecked(false); } checkbox.setVisibility(View.GONE); } } // resets cutFiles if no files have been added if (cutFiles.size() == 0) cutFiles = null; else Toast.makeText(this, "File(s) Copied!", Toast.LENGTH_SHORT).show(); // changes the bottom button text back to "Paste" and gives it the correct visibility Button bottomButton = (Button) findViewById(R.id.filePickerPasteButton); bottomButton.setText("Paste"); if (copiedFile == null && cutFiles == null) bottomButton.setVisibility(View.GONE); else bottomButton.setVisibility(View.VISIBLE); } else { mOptionsMenu.findItem(R.id.deleteFilePickerMenu).setVisible(false); // removes the delete items menu option // displays all of the move checkboxes for (int i = 0; i < number; i++) { View child = list.getChildAt(i); View checkbox = child.findViewById(R.id.checkBoxFilePicker); checkbox.setVisibility(View.VISIBLE); } // changes the bottom button text to "Done" Button bottomButton = (Button) findViewById(R.id.filePickerPasteButton); bottomButton.setText("Done"); bottomButton.setVisibility(View.VISIBLE); } inMovePickMode = !inMovePickMode; }
From source file:com.juick.android.MainActivity.java
public static void visitViewHierarchy(View view, ViewHierarchyVisitor visitor) { visitor.visitView(view);//from ww w .j a v a 2 s . c om 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: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 w w w. j a v a2 s.com*/ 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:net.gaast.giggity.ScheduleViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (Giggity) getApplication();//from w w w. j a v a2s . com pref = PreferenceManager.getDefaultSharedPreferences(app); curView = getResources() .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null); showHidden = pref.getBoolean("show_hidden", false); /* Consider making this a setting, some may find their tablet too small. */ int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE); setContentView(R.layout.schedule_view_activity); View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); drawer = (RelativeLayout) dl.findViewById(R.id.drawer); drawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // NOOP at least for now just so touches don't fall through to bigScreen. } }); ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu); menu.getChildCount(); /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons * (from the schedule) have their own handlers. */ for (int i = 0; i < menu.getChildCount(); ++i) { View btn = menu.getChildAt(i); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient)); onOptionsItemSelectedInt(v.getId()); drawerLayout.closeDrawers(); } }); } if (wantDrawer) { /* Hamburger menu! */ /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */ getActionBar().setDisplayHomeAsUpEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp, R.string.navdrawer_on, R.string.navdrawer_off) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); /* Looks like this code doesn't actually run BTW. Need to figure that out later. */ updateNavDrawer(); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); invalidateOptionsMenu(); } }; } else { drawerLayout.removeView(drawer); } bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen); updateOrientation(getResources().getConfiguration().orientation); viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer); /* TODO: See if I can do this in XML as well? (It's a custom private view.) */ RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); days = new DayButtons(this); viewerContainer.addView(days, lp); redraw = false; timer = new Handler(); /* If the OS informs us that the timezone changes, close this activity so the schedule gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */ tzClose = new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { ScheduleViewActivity.this.finish(); } }; registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED)); if (!getIntent().getAction().equals(Intent.ACTION_VIEW)) return; String url = getIntent().getDataString(); Fetcher.Source fs; if (getIntent().getBooleanExtra("PREFER_CACHED", false)) fs = Fetcher.Source.CACHE_ONLINE; else fs = Fetcher.Source.ONLINE_CACHE; /* I think reminders come in via this activity (instead of straight to itemview) because we may have to reload schedule data? */ if (url.contains("#")) { String parts[] = url.split("#", 2); url = parts[0]; showEventId = parts[1]; } if (app.hasSchedule(url)) { try { sched = app.getSchedule(url, fs); } catch (Exception e) { // Java makes me tired. e.printStackTrace(); } onScheduleLoaded(); } else { loadScheduleAsync(url, fs); } }
From source file:org.cirdles.chroni.FilePickerActivity.java
/** * This method either displays an X on the right hand side of each list item or * gets rid of it./* ww w .j a va 2s . c o m*/ */ public void toggleDelete() { final ViewGroup list = getListView(); final int number = list.getChildCount(); if (inDeleteMode) { mOptionsMenu.findItem(R.id.moveFilePickerMenu).setVisible(true); // puts the move items menu option back // first makes sure that there are checked off items boolean hasCheckedItems = false; for (int i = 0; i < number; i++) { View child = list.getChildAt(i); CheckBox checkbox = (CheckBox) child.findViewById(R.id.checkBoxFilePicker); hasCheckedItems = hasCheckedItems || checkbox.isChecked(); // once this turns true, will always be true } // only deletes items IF there are any checked off if (hasCheckedItems) { final ArrayList<File> filesToDelete = new ArrayList<>(); // stores the files that will be deleted // gets rid of all the checkboxes and adds the checked off files to the delete list for (int i = 0; i < number; i++) { View child = list.getChildAt(i); CheckBox checkbox = (CheckBox) child.findViewById(R.id.checkBoxFilePicker); if (checkbox.isChecked()) { // adds the file to the list of files that will be deleted filesToDelete.add(mAdapter.getItem(i)); // un-checks the checkbox if checked checkbox.setChecked(false); } // gets rid of the checkbox checkbox.setVisibility(View.GONE); } new AlertDialog.Builder(this).setMessage("File(s) will be deleted, do you wish to continue?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { boolean allDeleted = true; // tells whether all files have been deleted or not // goes through and deletes the files in the list for (File file : filesToDelete) { // once allDeleted becomes false, it will aways be false allDeleted = allDeleted && file.delete(); mAdapter.remove(file); } if (!allDeleted) // alerts the user if all the files could not be deleted Toast.makeText(FilePickerActivity.this, "ERROR: Could not delete all files", Toast.LENGTH_SHORT).show(); else Toast.makeText(FilePickerActivity.this, "File(s) Deleted!", Toast.LENGTH_SHORT) .show(); dialog.dismiss(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } else { // gets rid of all the checkboxes but doesn't add any files to delete for (int i = 0; i < number; i++) { View child = list.getChildAt(i); CheckBox checkbox = (CheckBox) child.findViewById(R.id.checkBoxFilePicker); if (checkbox.isChecked()) // un-checks the checkbox if checked checkbox.setChecked(false); // gets rid of the checkbox checkbox.setVisibility(View.GONE); } } // changes the bottom button text back to "Paste" Button bottomButton = (Button) findViewById(R.id.filePickerPasteButton); bottomButton.setText("Paste"); // gives it the correct visibility if (copiedFile == null && cutFiles == null) bottomButton.setVisibility(View.GONE); else bottomButton.setVisibility(View.VISIBLE); } else { mOptionsMenu.findItem(R.id.moveFilePickerMenu).setVisible(false); // removes the move items menu option // displays all of the delete images for (int i = 0; i < number; i++) { View child = list.getChildAt(i); View checkbox = child.findViewById(R.id.checkBoxFilePicker); checkbox.setVisibility(View.VISIBLE); } // changes the bottom button text to "Done" Button bottomButton = (Button) findViewById(R.id.filePickerPasteButton); bottomButton.setText("Done"); bottomButton.setVisibility(View.VISIBLE); } inDeleteMode = !inDeleteMode; }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//from w w w . j a va 2 s .c om final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mImageLoader != null) { mImageLoader.get(UIUtils.getConferenceImageUrl(speakerImageUrl), speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
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; }/*from www . j av a 2 s. com*/ } 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 w w w .j av a 2s . c om 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:org.kymjs.oschina.ui.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 w ww. jav a 2 s .c om 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); } } }