Example usage for android.widget LinearLayout getChildCount

List of usage examples for android.widget LinearLayout getChildCount

Introduction

In this page you can find the example usage for android.widget LinearLayout getChildCount.

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:com.cairoconfessions.MainActivity.java

public void updateFilters() {
    LinearLayout list = (LinearLayout) findViewById(R.id.confession_list);
    for (int i = 0; i < list.getChildCount(); i++) {
        View currDesc = list.getChildAt(i);
        String currLoc = ((TextView) ((LinearLayout) list.getChildAt(i)).findViewById(R.id.confess_loc))
                .getText().toString();/*from  www .  j  a va2  s. c o  m*/

        if (!Categories.isEmpty() && !Cities.isEmpty()) {
            if (!Categories.contains(currDesc.getContentDescription()) && !Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
            if (Categories.contains(currDesc.getContentDescription()) && !Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
            if (!Categories.contains(currDesc.getContentDescription()) && Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
            if (Categories.contains(currDesc.getContentDescription()) && Cities.contains(currLoc))
                if (mTitle.equals("Following")) {
                    if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow"))
                        currDesc.setVisibility(View.VISIBLE);
                } else
                    currDesc.setVisibility(View.VISIBLE);
        } else if (Categories.isEmpty() && !Cities.isEmpty()) {
            if (!Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
            if (Cities.contains(currLoc)) {
                if (mTitle.equals("Following")) {
                    if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow"))
                        currDesc.setVisibility(View.VISIBLE);
                } else
                    currDesc.setVisibility(View.VISIBLE);
            }
        } else if (!Categories.isEmpty() && Cities.isEmpty()) {
            if (!Categories.contains(currDesc.getContentDescription()))
                currDesc.setVisibility(View.GONE);
            if (Categories.contains(currDesc.getContentDescription())) {
                if (mTitle.equals("Following")) {
                    if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow"))
                        currDesc.setVisibility(View.VISIBLE);
                } else
                    currDesc.setVisibility(View.VISIBLE);
            }
        } else if (Categories.isEmpty() && Cities.isEmpty()) {
            if (mTitle.equals("Following")) {
                if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow"))
                    currDesc.setVisibility(View.VISIBLE);
            } else
                currDesc.setVisibility(View.VISIBLE);
        }
    }

}

From source file:com.cssweb.android.base.QuoteGridActivity.java

public void setSelectRow(int paramInt) throws Exception {
    LinearLayout localLinearLayout1 = this.mLinerLock;
    Integer localInteger1 = Integer.valueOf(this.m_nPos);
    View localView1 = localLinearLayout1.findViewWithTag(localInteger1);
    if (localView1 != null) {
        int l = this.residCol;
        //         int l = this.residSelColor;
        localView1.setBackgroundResource(l);
    }/*from   w w w .  java  2s  .  c  o m*/
    LinearLayout localLinearLayout2 = this.mLinerLock;
    Integer localInteger2 = Integer.valueOf(paramInt);
    View localView2 = localLinearLayout2.findViewWithTag(localInteger2);
    if (localView2 != null) {
        int i1 = this.residSelColor;
        localView2.setBackgroundColor(i1);
    }

    LinearLayout localLinearLayout3 = this.mLinerHScroll;
    Integer localInteger3 = Integer.valueOf(this.m_nPos);
    LinearLayout localLinearLayout4 = (LinearLayout) localLinearLayout3.findViewWithTag(localInteger3);

    if (localLinearLayout4 != null) {
        int i3 = localLinearLayout4.getChildCount();
        for (int i = 0; i < i3; i++) {
            View localView3 = localLinearLayout4.getChildAt(i);
            int i0 = 0;
            if (i == i3 - 1)
                i0 = this.residScrollCol[2];
            else if (i == 13)
                i0 = this.residScrollCol[1];
            else if (i % 2 == 0)
                i0 = this.residScrollCol[0];
            else
                i0 = this.residScrollCol[1];
            localView3.setBackgroundResource(i0);
        }
    }

    LinearLayout localLinearLayout5 = this.mLinerHScroll;
    Integer localInteger4 = Integer.valueOf(paramInt);
    LinearLayout localLinearLayout6 = (LinearLayout) localLinearLayout5.findViewWithTag(localInteger4);
    if (localLinearLayout6 != null) {
        int i4 = this.residSelColor;
        localLinearLayout6.setBackgroundColor(i4);
    }
    int i6 = localLinearLayout6.getChildCount();
    for (int i = 0; i < i6; i++) {
        View localView6 = localLinearLayout6.getChildAt(i);
        int i10 = this.residSelColor;
        localView6.setBackgroundColor(i10);
    }

    this.m_nPos = paramInt;
    this.cssStock = list.get(paramInt - 1);
}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

private int getCheckedItemPosition(LinearLayout parent) {
    int selectedPos = -1;
    int childCount = parent.getChildCount();
    boolean found = false;
    CheckableLinearLayout tv;//from w  ww.j a  va 2s  .  co  m

    for (int i = 0; !found && (i < childCount); i++) {
        tv = (CheckableLinearLayout) parent.getChildAt(i);
        found = tv.isChecked();

        if (found) {
            selectedPos = i;
        }
    }

    return selectedPos;
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    LinearLayout controlLayout = (LinearLayout) findViewById(R.id.controls_list);
    for (int i = 0; i < controlLayout.getChildCount(); i++)
        if (controlLayout.getChildAt(i) instanceof IControl)
            ((IControl) controlLayout.getChildAt(i)).saveState(outState);

    super.onSaveInstanceState(outState);
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

protected void ShowHideEpisodes(View seasonRow) {

    // Get the linear layout that we will be adding/removing the episodes to/from
    LinearLayout epLinearLayout = (LinearLayout) seasonRow;

    if (epLinearLayout.getChildCount() == 1) { // if collapsed, expand (add) the seasons

        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_down),
                null, null, null);/*from w ww  .  j  a v  a 2s  .  c o  m*/

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        for (int i = 0; i < episodeList.size(); i++) {
            if (seasonRow.getId() == episodeList.get(i).getSeason()) {
                View episodeView = inflater.inflate(R.layout.episode_text_row, epLinearLayout, false);

                episodeView.setBackgroundColor(
                        AppSettings.listBackgroundColors[i % AppSettings.listBackgroundColors.length]);

                TextView text = (TextView) episodeView.findViewById(R.id.text);
                String nameText = String.format("%02d", episodeList.get(i).getNumber()) + " "
                        + episodeList.get(i).getName();
                text.setText(nameText);
                text.setTextSize(textSize);
                text.setId(episodeList.get(i).getId());

                episodeView.setOnClickListener(episodeListener);
                epLinearLayout.addView(episodeView);
            }
        }
    } else { // else season is expanded, collapse it
        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_right),
                null, null, null);

        for (int i = epLinearLayout.getChildCount() - 1; i > 0; i--) {
            epLinearLayout.removeView(epLinearLayout.getChildAt(i));
        }

    }

}

From source file:org.wheelmap.android.activity.MainMultiPaneActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    ActionBar bar = getSupportActionBar();
    if (bar == null) {
        return true;
    }//from  ww w  .jav a2  s. c  o m

    LayoutInflater inflater = LayoutInflater.from(this);
    View customView = inflater.inflate(R.layout.actionbar_tablet, null);
    bar.setCustomView(customView, new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.END));

    boolean isPortraitMode = getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortraitMode) {

        ImageView addItem = (ImageView) customView.findViewById(R.id.menu_new_poi);
        addItem.setVisibility(View.VISIBLE);
        OnClickListener addClickListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                createNewPoi();
            }
        };
        addItem.setOnClickListener(addClickListener);

        LinearLayout l = (LinearLayout) findViewById(R.id.actionbar_bottom);
        for (int i = 0; i < l.getChildCount(); i++) {
            l.getChildAt(i).setOnTouchListener(new PressSelector());
        }

        bar.setDisplayShowCustomEnabled(true);
        View v = findViewById(R.id.menu_filter);
        MapActivityUtils.setAccessFilterOptionDrawable(this, null, v);

        View filterWc = findViewById(R.id.menu_wc);
        MapActivityUtils.setWcFilterOptionsDrawable(this, null, filterWc);

        UserCredentials credentials = new UserCredentials(getApplicationContext());
        ImageView image = (ImageView) findViewById(R.id.menu_login);
        image.setImageResource(
                credentials.isLoggedIn() ? R.drawable.start_icon_logged_in : R.drawable.start_icon_login);
    } else {
        MenuInflater inflaterMenu = getMenuInflater();
        inflaterMenu.inflate(R.menu.ab_multi_activity, menu);
        MenuItem item = menu.findItem(R.id.menu_filter);
        MapActivityUtils.setAccessFilterOptionDrawable(this, item, null);
        item = menu.findItem(R.id.menu_wc);
        MapActivityUtils.setWcFilterOptionsDrawable(this, item, null);

    }

    if (mapModeType == MapModeType.MAP_MODE_ENGAGE) {
        MenuItem itemFilterWheelChairs = menu.findItem(R.id.menu_filter);
        itemFilterWheelChairs.setEnabled(false);
        //TODO Disable it - doesn't work yet
    }

    ImageView listMapToggle = (ImageView) findViewById(R.id.switch_view);
    if (listMapToggle != null) {
        listMapToggle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                toggleMovableResize();
            }
        });
    }

    return true;
}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

private SparseBooleanArray getCheckedItemPositions(LinearLayout parent) {
    SparseBooleanArray checkedItems = new SparseBooleanArray();
    int childCount = parent.getChildCount();
    CheckableLinearLayout tv;/* w  w w .j a  v  a 2  s .  com*/

    for (int i = 0; i < childCount; i++) {
        tv = (CheckableLinearLayout) parent.getChildAt(i);
        checkedItems.append(i, tv.isChecked());
    }

    return checkedItems;
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

protected void putSign() {
    LinearLayout layout = (LinearLayout) findViewById(R.id.controls_list);
    for (int i = 0; i < layout.getChildCount(); i++) {
        View child = layout.getChildAt(i);
        if (child instanceof Sign) {
            IGISApplication application = (IGISApplication) getApplication();
            Uri uri = Uri.parse("content://" + application.getAuthority() + "/" + mLayer.getPath().getName()
                    + "/" + mFeatureId + "/" + Constants.URI_ATTACH);

            ContentValues values = new ContentValues();
            values.put(VectorLayer.ATTACH_DISPLAY_NAME, "_signature");
            values.put(VectorLayer.ATTACH_DESCRIPTION, "_signature");
            values.put(VectorLayer.ATTACH_MIME_TYPE, "image/jpeg");

            Cursor saved = getContentResolver().query(uri, null, VectorLayer.ATTACH_ID + " =  ?",
                    new String[] { Sign.SIGN_FILE }, null);
            boolean hasSign = false;
            if (saved != null) {
                hasSign = saved.moveToFirst();
                saved.close();/*w  w w.  j a v a  2 s .c  om*/
            }

            if (!hasSign) {
                Uri result = getContentResolver().insert(uri, values);
                if (result != null) {
                    long id = Long.parseLong(result.getLastPathSegment());
                    values.clear();
                    values.put(VectorLayer.ATTACH_ID, Integer.MAX_VALUE);
                    uri = Uri.withAppendedPath(uri, id + "");
                    getContentResolver().update(uri, values, null, null);
                }
            }

            File png = new File(mLayer.getPath(), mFeatureId + "");
            Sign sign = (Sign) child;
            try {
                if (!png.isDirectory())
                    FileUtil.createDir(png);

                png = new File(png, Sign.SIGN_FILE);
                sign.save(sign.getWidth(), sign.getHeight(), true, png);
            } catch (IOException | RuntimeException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:org.catrobat.catroid.ui.fragment.FormulaEditorFragment.java

@Override
public void onStart() {
    formulaEditorKeyboard.setClickable(true);
    formulaEditorFieldDeleteButton.setClickable(true);

    getView().requestFocus();//ww w  .j a v a 2  s  .  c  om
    View.OnTouchListener touchListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                updateButtonsOnKeyboardAndInvalidateOptionsMenu();
                view.setPressed(false);
                return true;
            }

            if (event.getAction() == MotionEvent.ACTION_DOWN) {

                view.setPressed(true);

                switch (view.getId()) {
                case R.id.formula_editor_keyboard_compute:
                    InternFormulaParser internFormulaParser = formulaEditorEditText.getFormulaParser();
                    FormulaElement formulaElement = internFormulaParser.parseFormula();
                    if (formulaElement == null) {
                        if (internFormulaParser.getErrorTokenIndex() >= 0) {
                            formulaEditorEditText.setParseErrorCursorAndSelection();
                        }
                        return false;
                    }
                    Formula formulaToCompute = new Formula(formulaElement);
                    FormulaEditorComputeDialog computeDialog = new FormulaEditorComputeDialog(context);
                    computeDialog.setFormula(formulaToCompute);
                    computeDialog.show();
                    return true;
                case R.id.formula_editor_keyboard_function:
                    showFormulaEditorListFragment(FormulaEditorListFragment.FUNCTION_TAG,
                            R.string.formula_editor_math);
                    return true;
                case R.id.formula_editor_keyboard_logic:
                    showFormulaEditorListFragment(FormulaEditorListFragment.LOGIC_TAG,
                            R.string.formula_editor_logic);
                    return true;
                case R.id.formula_editor_keyboard_object:
                    showFormulaEditorListFragment(FormulaEditorListFragment.OBJECT_TAG,
                            R.string.formula_editor_choose_object_variable);
                    return true;
                case R.id.formula_editor_keyboard_sensors:
                    showFormulaEditorListFragment(FormulaEditorListFragment.SENSOR_TAG,
                            R.string.formula_editor_sensors);
                    return true;
                case R.id.formula_editor_keyboard_data:
                    showFormulaEditorDataFragment(FormulaEditorDataFragment.USER_DATA_TAG,
                            R.string.formula_editor_data);
                    return true;
                case R.id.formula_editor_keyboard_ok:
                    endFormulaEditor();
                    return true;
                case R.id.formula_editor_keyboard_string:
                    FragmentManager fragmentManager = ((SherlockFragmentActivity) context)
                            .getSupportFragmentManager();
                    Fragment dialogFragment = fragmentManager
                            .findFragmentByTag(NewStringDialog.DIALOG_FRAGMENT_TAG);

                    if (dialogFragment == null) {
                        dialogFragment = NewStringDialog.newInstance();
                    }

                    ((NewStringDialog) dialogFragment).show(fragmentManager,
                            NewStringDialog.DIALOG_FRAGMENT_TAG);
                    return true;
                default:
                    formulaEditorEditText.handleKeyEvent(view.getId(), "");
                    return true;
                }
            }
            return false;
        }
    };

    for (int index = 0; index < formulaEditorKeyboard.getChildCount(); index++) {
        LinearLayout child = (LinearLayout) formulaEditorKeyboard.getChildAt(index);
        for (int nestedIndex = 0; nestedIndex < child.getChildCount(); nestedIndex++) {
            View view = child.getChildAt(nestedIndex);
            view.setOnTouchListener(touchListener);
        }
    }
    formulaEditorFieldDeleteButton.setOnTouchListener(touchListener);

    updateButtonsOnKeyboardAndInvalidateOptionsMenu();

    super.onStart();
}

From source file:com.seraphim.chips.ChipsVerticalLinearLayout.java

public TextLineParams onChipsChanged(List<ChipsView.Chip> chips) {
    clearChipsViews();//from w  w  w.j a v a 2 s.c  o  m

    int width = getWidth();
    if (width == 0) {
        return null;
    }
    int widthSum = 0;
    int rowCounter = 0;

    LinearLayout ll = createHorizontalView();

    for (ChipsView.Chip chip : chips) {
        View view = chip.getView();
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

        // if width exceed current width. create a new LinearLayout
        if (widthSum + view.getMeasuredWidth() > width) {
            rowCounter++;
            widthSum = 0;
            ll = createHorizontalView();
        }

        widthSum += view.getMeasuredWidth();
        ll.addView(view);
    }

    // check if there is enough space left
    if (width - widthSum < width * 0.1f) {
        widthSum = 0;
        rowCounter++;
    }
    widthSum += Math.round(ll.getChildCount() * (float) 8 * density);
    return new TextLineParams(rowCounter, widthSum);
}