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:app.jorge.mobile.com.transportalert.ScrollingActivity.java

@Override
public void onResponse(Response<List<StatusLine>> response, Retrofit retrofit) {
    if (response.isSuccess()) {

        tubeStatus = new HashMap<>();

        int size = response.body().size();
        for (int i = 0; i < size; i++) {

            StatusLine statusLine = response.body().get(i);

            String nameKey = statusLine.getName();
            LineStatuses lineStatuses = statusLine.getLineStatuses().get(0);

            //String status =response.body().get(i).getLineStatuses().get(0).getStatusSeverityDescription();
            tubeStatus.put(nameKey, lineStatuses);
        }/*from   w  w w.j  a va 2  s  .c  o  m*/
        //String name=response.body().get(0).getName();
        //String status =response.body().get(0).getLineStatuses().get(0).getStatusSeverityDescription();

        // Toast.makeText( getContext(), "You Clicked hey "+ status, Toast.LENGTH_SHORT).show();

        LinearLayout item = (LinearLayout) findViewById(R.id.rv);
        int childcount = item.getChildCount();
        for (int i = 0; i < childcount; i++) {
            View child = item.getChildAt(i);

            TextView lineName = (TextView) child.findViewById(R.id.tubeName);
            String line_id = lineName.getText().toString();

            String message = tubeStatus.get(line_id).getStatusSeverityDescription();
            if (message != null) {
                TextView text = (TextView) child.findViewById(R.id.tubeStatus);
                text.setText(message);
            }
        }

    } else {
        int statusCode = response.code();

        // handle request errors
        ResponseBody errorBody = response.errorBody();
        Toast.makeText(getApplicationContext(), "Error code " + errorBody.toString() + " " + statusCode,
                Toast.LENGTH_SHORT).show();
    }
}

From source file:com.android.together.BaseActivity.java

protected void initMenu() {

    menu = new SlidingMenu(this);//newgetSlidingMenu

    menu.setMode(SlidingMenu.LEFT);/*from w w  w  . ja  va2  s .  co  m*/

    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);

    //menu.setShadowDrawable(R.drawable.shadow);

    //menu.setShadowWidthRes(R.dimen.shadow_width);

    //menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);

    menu.setBehindWidth(mScreenWidth / 10 * 7);//SlidingMenu

    menu.setFadeDegree(0.5f);

    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);//

    menu.setMenu(R.layout.menu_layout);//layout

    //menu.setSecondaryMenu(R.layout.menu_layout);//layout

    //menu.setBehindCanvasTransformer(mTransformer);

    menuItemClickListner = new MyMenuItemClickListner();

    LinearLayout layout_item = (LinearLayout) menu.findViewById(R.id.layout_item);

    for (int i = 0; i < layout_item.getChildCount(); i++) {
        LinearLayout item = (LinearLayout) layout_item.getChildAt(i);
        item.setOnClickListener(menuItemClickListner);
    }
}

From source file:org.mifos.androidclient.main.CustomerDetailsActivity.java

private void updateContent(CustomerDetailsEntity details) {
    if (details != null) {
        mDetails = details;/*from   w  w  w  .j  a  v a  2 s  .c om*/
        LinearLayout tabContent = (LinearLayout) findViewById(R.id.customer_overview);
        ViewBuilderFactory factory = new ViewBuilderFactory(this);
        CustomerDetailsViewBuilder builder = factory.createCustomerDetailsViewBuilder(details);
        View view;

        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        tabContent.addView(builder.buildOverviewView());

        tabContent = (LinearLayout) findViewById(R.id.customer_accounts);
        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        view = builder.buildAccountsView();
        setupAccountsListListeners(view);
        tabContent.addView(view);

        tabContent.addView(builder.buildAccountsView());

        tabContent = (LinearLayout) findViewById(R.id.customer_additional);
        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        tabContent.addView(builder.buildAdditionalView());
    }
}

From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java

protected int getNumberOfNotVisibleTools() {
    LinearLayout toolsLayout = (LinearLayout) mSolo.getView(R.id.tools_layout);
    int toolCount = toolsLayout.getChildCount();
    int numberOfNotVisibleTools = 0;
    for (int i = 0; i < toolCount; i++) {
        View toolButton = toolsLayout.getChildAt(i);
        if (!toolButton.isShown())
            numberOfNotVisibleTools++;/*from w w w. j  a v  a  2s .c o  m*/
    }
    return numberOfNotVisibleTools;
}

From source file:com.nadmm.airports.aeronav.ChartsDownloadFragment.java

protected View addTppVolumeRow(LinearLayout layout, String tppVolume, int total) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);/*w  w w  .jav  a  2s.  co m*/
    }

    RelativeLayout row = (RelativeLayout) inflate(R.layout.list_item_with_progressbar);

    TextView tv = (TextView) row.findViewById(R.id.item_label);
    tv.setText(tppVolume);
    tv = (TextView) row.findViewById(R.id.item_value);
    tv.setText(String.format("%d charts", total));

    row.setTag(R.id.DTPP_VOLUME_NAME, tppVolume);
    row.setTag(R.id.DTPP_CHART_TOTAL, total);

    showStatus(row, 0, total);

    layout.addView(row, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mVolumeRowMap.put(tppVolume, row);
    getChartCount(mTppCycle, tppVolume);

    return row;
}

From source file:org.ale.scanner.zotero.EditItemActivity.java

private void extractValues() throws JSONException {
    JSONObject info = mWorkingItem.getSelectedInfo();

    LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer));
    LinearLayout row;//from ww w .  ja v a2  s .  c  o  m
    LinearLayout crow;
    for (int i = 0; i < container.getChildCount(); i++) {
        row = (LinearLayout) container.getChildAt(i);

        switch (row.getId()) {
        case R.id.edit_field:
            TextView tv = (TextView) row.findViewById(R.id.label);
            EditText et = (EditText) row.findViewById(R.id.content);
            String label = (String) tv.getTag();
            String content = et.getText().toString();
            info.put(label, content);
            break;

        case R.id.edit_creators:
            JSONArray creators = new JSONArray();
            JSONObject creator;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                EditText name = (EditText) crow.findViewById(R.id.creator);
                if (TextUtils.isEmpty(name.getText().toString())) {
                    continue;
                }
                Spinner sp = (Spinner) crow.findViewById(R.id.creator_type);
                creator = new JSONObject();
                int indx = CreatorType.LocalizedBook.indexOf((String) sp.getSelectedItem());
                creator.put(CreatorType.type, CreatorType.Book.get(indx));
                creator.put(ItemField.Creator.name, name.getText().toString());
                creators.put(creator);
            }
            info.put(ItemField.creators, creators);
            break;

        case R.id.edit_notes:
            JSONArray notes = new JSONArray();
            JSONObject note;
            EditText note_et;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                note_et = (EditText) crow.findViewById(R.id.content);
                String note_content = note_et.getText().toString();
                if (TextUtils.isEmpty(note_content))
                    continue;

                note = new JSONObject();
                note.put(ItemField.Note.itemType, ItemField.Note.note);
                note.put(ItemField.Note.note, note_content);
                notes.put(note);
            }
            info.put(ItemField.notes, notes);
            break;

        case R.id.edit_tags:
            JSONArray tags = new JSONArray();
            JSONObject tag;
            EditText tag_et;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                tag_et = (EditText) crow.findViewById(R.id.content);
                String tag_content = tag_et.getText().toString();
                if (TextUtils.isEmpty(tag_content))
                    continue;

                tag = new JSONObject();
                tag.put(ItemField.Tag.tag, tag_content);
                tags.put(tag);
            }
            info.put(ItemField.tags, tags);
            break;

        default:
            break;
        }
    }
}

From source file:com.nadmm.airports.FragmentBase.java

protected View addRow(LinearLayout layout, View row) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);//from  w w w. j  a va2  s .  c  o m
    }

    layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return row;
}

From source file:com.nadmm.airports.FragmentBase.java

protected View addProgressRow(LinearLayout layout, String label) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);//from  w ww  .  j  av a2 s.  c o  m
    }
    LinearLayout row = (LinearLayout) inflate(R.layout.list_item_text1);
    TextView tv = (TextView) row.findViewById(R.id.text);
    tv.setText(label);
    layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return row;
}

From source file:com.bridgeconn.autographago.ui.customviews.TabLayoutHelper.java

protected 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;
    }/*from  www .  j  av  a  2s. co 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:cn.com.incito.driver.UI.detailDialog.PCCFragmentActivity.java

/**
 * /*w  w w. j  av  a 2  s .c o  m*/
 */
private void notifySelectedCities() {
    LinearLayout selectedLayout = (LinearLayout) findViewById(R.id.selected_cities_linearlayout);
    for (int i = 0; i < selectedLayout.getChildCount(); i++) {
        Button selectedBtn = (Button) selectedLayout.getChildAt(i);
        if (i < selectedCities.size() && selectedCities.get(i) != null) {
            selectedBtn.setVisibility(View.VISIBLE);
            ModelSelectedCity selectedCity = selectedCities.get(i);
            if (selectedCity.country != null && !TextUtils.isEmpty(selectedCity.country)) {
                selectedBtn.setText(selectedCity.country);
            } else if (selectedCity.city != null && !TextUtils.isEmpty(selectedCity.city)) {
                selectedBtn.setText(selectedCity.city);
            } else {
                selectedBtn.setText(selectedCity.province);
            }
        } else {
            selectedBtn.setVisibility(View.GONE);
        }
    }
}