Example usage for android.widget LinearLayout getChildAt

List of usage examples for android.widget LinearLayout getChildAt

Introduction

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

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:info.papdt.blacklight.support.adapter.WeiboAdapter.java

private void bindMultiPicLayout(ViewHolder h, MessageModel msg, boolean showPic) {
    if (showPic && h.getItemViewType() % 10 > 0) {
        LinearLayout container = h.pics;

        int numChilds = h.getItemViewType() % 10;

        for (int i = 0; i < numChilds; i++) {
            ImageView iv = (ImageView) container.getChildAt(i);

            String url = null;//from   w  w  w. j ava2s .  c om
            if (msg.hasMultiplePictures()) {
                url = msg.pic_urls.get(i).getThumbnail();
            } else if (i == 0) {
                url = msg.thumbnail_pic;
            }

            Picasso.with(iv.getContext()).load(url).fit().centerCrop().into(iv);

            iv.setTag(TAG_MSG, msg);
        }
    }
}

From source file:com.amrutpatil.makeanote.NotesActivity.java

private void moveToArchive(View view, int position) {
    ContentValues contentValues = new ContentValues();
    TextView title = (TextView) findViewById(R.id.title_note_custom_home);
    TextView description = (TextView) findViewById(R.id.description_note_custom_home);
    TextView dateTime = (TextView) findViewById(R.id.date_time_note_custom_home);

    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.home_list);
    int isList = linearLayout.getVisibility();
    String listDescription = "";
    if (isList == View.VISIBLE) {
        //If a note contains list of items
        NoteCustomList noteCustomList = (NoteCustomList) linearLayout.getChildAt(0);
        listDescription = noteCustomList.getLists();
        //            for(int i = 0 ; i < noteCustomList.getChildCount(); i++){
        //                LinearLayout first = (LinearLayout) linearLayout.getChildAt(i);
        //                CheckBox checkBox = (CheckBox) first.getChildAt(0);
        //                TextView textView = (TextView) first.getChildAt(1);
        //                listDescription = description + textView.toString() + checkBox.isChecked() + "%";
        //            }
        contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TYPE, AppConstant.LIST);
    } else {//www  .  ja  va 2  s  . c  om
        listDescription = description.getText().toString();
        contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TYPE, AppConstant.NORMAL);
    }

    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_DESCRIPTION, listDescription);
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TITLE, title.getText().toString());
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_DATE_TIME, dateTime.getText().toString());
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_CATEGORY, mTitle);

    ContentResolver cr = this.getContentResolver();
    Uri uri = ArchivesContract.URI_TABLE;
    cr.insert(uri, contentValues);
    delete(view, position);
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java

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

    getView().requestFocus();//from   w ww  .  ja v a2  s.co  m
    View.OnTouchListener touchListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            Log.i("info", "viewId: " + view.getId());
            if (event.getAction() == MotionEvent.ACTION_UP) {
                updateButtonViewOnKeyboard();
                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_undo:
                    formulaEditorEditText.undo();
                    return true;
                case R.id.formula_editor_keyboard_redo:
                    formulaEditorEditText.redo();
                    return true;
                case R.id.formula_editor_keyboard_math:
                    showFormulaEditorListFragment(FormulaEditorListFragment.MATH_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_scripts:
                    showFormulaEditorScriptListFragment(FormulaEditorScriptListFragment.SCRIPT_TAG,
                            R.string.formula_editor_scripts);
                    return true;
                case R.id.formula_editor_keyboard_variables:
                    showFormulaEditorVariableListFragment(FormulaEditorVariableListFragment.VARIABLE_TAG,
                            R.string.formula_editor_variables);
                    return true;
                case R.id.formula_editor_keyboard_ok:
                    endFormulaEditor();
                    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);
        }
    }
    formularEditorFieldDeleteButton.setOnTouchListener(touchListener);

    updateButtonViewOnKeyboard();

    super.onStart();
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

protected void refreshTable(List<String[]> list, int scrollNum, String exchange) throws JSONException {
    double d0 = 0;
    clearData(scrollNum);//from   w  ww. j  a v  a 2 s. c  om

    if (null != list) {
        initQuote();

        for (int i = 1; i <= list.size(); i++) {
            try {
                String[] cs = list.get(i - 1);
                d0 = Double.parseDouble(cs[cs.length - 1]);
                // ??
                int digit = Utils.getStockDigit(NameRule.getSecurityType(exchange, cs[cs.length - 3]));

                LinearLayout localLinearLayout = (LinearLayout) this.mLinerHScroll.findViewWithTag(i);
                int i6 = localLinearLayout.getChildCount();
                for (int j = 0; j < i6; j++) {
                    TextView localView6 = (TextView) localLinearLayout.getChildAt(j);
                    // Log.i("tag", "cs[j]"+cs[j]);
                    double zf = Double.parseDouble(cs[j]);

                    if (j == 0) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 2) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 1) {// 
                        String str1;
                        if (zf == 0)
                            str1 = Utils.dataFormation(zf * 100, 1);
                        else
                            str1 = Utils.dataFormation(zf * 100, 1);
                        localView6.setTextColor(Utils.getTextColor(mContext, zf));
                        localView6.setText(str1);

                    } else if (j == 3 || j == 4) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 5 || j == 6) {// ???
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 7) {// ?
                        localView6.setTextColor(
                                Utils.getTextColor(mContext, Utils.getColorFromBS(cs[cs.length - 4])));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 8) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.getAmountFormat(zf, true, 2));
                    } else if (j == 9 || j == 10 || j == 11) {// ,
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 17) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, 0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 12) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 13) {// 
                        localView6.setTextColor(Utils.getTextColor(mContext, zf, d0));
                        localView6.setText(Utils.dataFormation(zf, digit, 0));
                    } else if (j == 14 || j == 15) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 1));
                        localView6.setText(Utils.dataFormation(zf, digit));
                    } else if (j == 16) {// ?
                        localView6.setTextColor(Utils.getTextColor(mContext, 2));
                        localView6.setText(Utils.getAmountFormat(zf, false, 2));
                    }

                    // ???t? 1
                    // ?t? 0
                    // //?, ? d0
                    // , 0
                    // Utils.getAmountFormat(zf, false)
                    // Utils.dataFormation(zf, mDigit)

                    // Utils.getTextColor(mContext, zf, d0) 
                    // Utils.getTextColor(mContext, zf) 0
                    // Utils.getTextColor(mContext, 1) ?t?

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.cw.litenote.tabs.TabsHost.java

/**
 * Set long click listeners for tabs editing
 *//*www.j  av a 2  s  .c om*/
void setLongClickListener() {
    //        System.out.println("TabsHost / _setLongClickListener");

    //https://stackoverflow.com/questions/33367245/add-onlongclicklistener-on-android-support-tablayout-tablayout-tab
    // on long click listener
    LinearLayout tabStrip = (LinearLayout) mTabLayout.getChildAt(0);
    final int tabsCount = tabStrip.getChildCount();
    for (int i = 0; i < tabsCount; i++) {
        final int tabPos = i;
        tabStrip.getChildAt(tabPos).setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                editPageTitle(tabPos, MainAct.mAct);
                return false;
            }
        });
    }
}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

/**
 * Add new text view to the linear layout that contains the tab title*
 * @param position of the linear layout in the tabsContainer
 * @param text is the text of the subtitle
 *///from   ww  w.j  av  a2 s. co m
public void addSubtitleAtTab(int position, String text) {
    LinearLayout tab = getSingleTabLayoutAtPosition(position);
    tab.setWeightSum(tab.getChildCount() + 1);
    if (tab.getChildCount() == 1) {
        tab.getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));
    }

    ((TextView) tab.getChildAt(0)).setGravity(Gravity.CENTER_HORIZONTAL);

    TextView newSubTab = new TextView(getContext());
    newSubTab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));
    newSubTab.setText(text);
    newSubTab.setGravity(Gravity.CENTER_HORIZONTAL);

    tab.addView(newSubTab);
    updateTabStyles();
}

From source file:com.cssweb.android.quote.QHSCGridActivity.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;
        localView1.setBackgroundResource(l);
    }/*  w w w  . j  a va2  s. com*/
    LinearLayout localLinearLayout2 = this.mLinerLock;
    Integer localInteger2 = Integer.valueOf(paramInt);
    View localView2 = localLinearLayout2.findViewWithTag(localInteger2);
    if (localView2 != null) {
        int i1 = this.residSelColor;
        localView2.setBackgroundColor(i1);
    }

    if (true) {
        LinearLayout localLinerLock = this.mLinerLock2;
        Integer localLockInteger = Integer.valueOf(this.m_nPos);
        View localLockView = localLinerLock.findViewWithTag(localLockInteger);
        if (localLockView != null) {
            int l = this.residCol;
            localLockView.setBackgroundResource(l);
        }
        LinearLayout localLinerLock2 = this.mLinerLock2;
        Integer localLockInteger2 = Integer.valueOf(paramInt);
        View localLockView2 = localLinerLock2.findViewWithTag(localLockInteger2);
        if (localLockView2 != null) {
            int i1 = this.residSelColor;
            localLockView2.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;

    if (null != stringList && stringList.size() > paramInt && null != temp2[m_nPos - 1]
            && !"".equals(temp2[m_nPos - 1]) && null != temp1[m_nPos - 1] && !"".equals(temp1[m_nPos - 1])
            && temp1[m_nPos - 1].length() > 2) {

        Log.i("tag", "stringList.length" + stringList.size() + " : paramInt : " + paramInt);

        String[] data = stringList.get(paramInt - 1);
        String market = data[data.length - 2];
        cssStock = new CssStock();
        cssStock.setStkcode(temp1[m_nPos - 1].substring(2)); // 
        cssStock.setStkname(temp2[m_nPos - 1]);
        cssStock.setMarket(market);
    }
    // this.cssStock = list.get(paramInt - 1);
}

From source file:com.cairoconfessions.MainActivity.java

public void updateFiltersDelete() {
    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();/*  w  ww.  j  a v a2s .  c o m*/

        if (!Categories.isEmpty() && !Cities.isEmpty()) {
            if (!Categories.contains(currDesc.getContentDescription()) && !Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
        } else if (!Categories.isEmpty()) {
            if (!Categories.contains(currDesc.getContentDescription()))
                currDesc.setVisibility(View.GONE);
        } else if (!Cities.isEmpty()) {
            if (!Cities.contains(currLoc))
                currDesc.setVisibility(View.GONE);
        } else if (Categories.isEmpty() && Cities.isEmpty()) {
            currDesc.setVisibility(View.VISIBLE);
        } else if (Cities.isEmpty()) {
            if (Categories.contains(currDesc.getContentDescription()))
                currDesc.setVisibility(View.VISIBLE);
        } else if (Categories.isEmpty())
            if (Cities.contains(currLoc))
                currDesc.setVisibility(View.VISIBLE);
    }

}

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    Toolbar bar;/*from w  w w. ja v  a 2  s.c om*/

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
        root.addView(bar, 0); // insert at top
    } else {
        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
        ListView content = (ListView) root.getChildAt(0);
        root.removeAllViews();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);

        int height;
        TypedValue tv = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
            height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        } else {
            height = bar.getHeight();
        }
        content.setPadding(0, height, 0, 0);

        root.addView(content);
        root.addView(bar);
    }
    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.ssn.currency.convertor.WheelView.java

/**
 * Calculates desired height for layout//from   w  w w.j  a va2 s .com
 * 
 * @param layout
 *            the source layout
 * @return the desired layout height
 */
private int getDesiredHeight(LinearLayout layout) {
    if (layout != null && layout.getChildAt(0) != null) {
        itemHeight = layout.getChildAt(0).getMeasuredHeight();
    }

    int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;

    return Math.max(desired, getSuggestedMinimumHeight());
}