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.cssweb.android.quote.QHSCGridActivity.java

protected void initTitle(int pageNum, String[] cols, boolean nameOrCodeFlag) {
    TextView localView6 = (TextView) this.mLinerLock.getChildAt(0);
    TextView localView7 = (TextView) this.mLinerLock2.getChildAt(0);

    if (n2 == 0) {
        String str = (n1 == 0) ? cols[0] + low : (n1 == 1) ? cols[0] + top : cols[0];
        localView6.setText(str);//from  www.  j  a  va  2  s .  c o m
    } else {
        localView6.setText(cols[0]);
    }

    localView7.setText(cols[1]);

    LinearLayout localLinearLayout = (LinearLayout) this.mLinerHScroll.findViewWithTag(0);
    int i6 = localLinearLayout.getChildCount();
    for (int j = 0; j < i6; j++) {
        TextView localView8 = (TextView) localLinearLayout.getChildAt(j);
        if (n2 == -(j + 2)) {
            String str = (n1 == 0) ? cols[j + 2] + low : (n1 == 1) ? cols[j + 2] + top : cols[j + 2];
            localView8.setText(str);
        } else {
            localView8.setText(cols[j + 2]);
        }
    }
}

From source file:me.tipi.kiosk.ui.fragments.IdentityFragment.java

/**
 * Style date picker.//from ww  w. jav a2s  .  co m
 *
 * @param datePicker the date picker
 */
private void styleDatePicker(DatePicker datePicker) {
    datePicker.setCalendarViewShown(false);
    datePicker.setSpinnersShown(true);
    LinearLayout llFirst = (LinearLayout) datePicker.getChildAt(0);
    LinearLayout llSecond = (LinearLayout) llFirst.getChildAt(0);
    for (int i = 0; i < llSecond.getChildCount(); i++) {
        NumberPicker picker = (NumberPicker) llSecond.getChildAt(i); // NumberPickers in llSecond
        Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                try {
                    pf.set(picker, ContextCompat.getDrawable(getActivity(), R.drawable.picker_divider));
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (Resources.NotFoundException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
}

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

protected View addRow(LinearLayout layout, String label1, String value1, String label2, String value2) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);//from w  w w  . j  a  v  a2  s.  c  om
    }

    LinearLayout row = (LinearLayout) inflate(R.layout.detail_row_item4);
    TextView tv = (TextView) row.findViewById(R.id.item_label);
    tv.setText(label1);
    tv = (TextView) row.findViewById(R.id.item_value);
    if (value1 != null && value1.length() > 0) {
        tv.setText(value1);
    } else {
        tv.setVisibility(View.GONE);
    }
    tv = (TextView) row.findViewById(R.id.item_extra_label);
    if (label2 != null && label2.length() > 0) {
        tv.setText(label2);
    } else {
        tv.setVisibility(View.GONE);
    }
    tv = (TextView) row.findViewById(R.id.item_extra_value);
    if (value2 != null && value2.length() > 0) {
        tv.setText(value2);
    } else {
        tv.setVisibility(View.GONE);
    }
    layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return row;
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java

/**
 * On click image view to start stop recording 
 * /* ww  w .  j  a  v  a2 s  . c  o m*/
 * Records time SYNCHRONOUSLY
 * 
 * @param v
 */
public void onClickSwitchAction(View v) {

    Drawable drwStart = getResources().getDrawable(R.drawable.play);
    Drawable drwStop = getResources().getDrawable(R.drawable.stop);

    LinearLayout lllFrag = (LinearLayout) v.getParent();
    LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker);
    LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus);
    TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording);
    ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording);

    Animation anim = new AlphaAnimation(0.0f, 1.0f);

    Log.d(CLASSNAME,
            "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString());

    ImageView iv = (ImageView) v;
    int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus();

    if (currentStatus == ActivitySession.STATUS_STOPPED) {
        Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED");
        iv.setImageDrawable(drwStop);
        llTimePicker.setVisibility(View.INVISIBLE);

        anim.setDuration(500);
        anim.setStartOffset(20);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);

        Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn();

    } else {
        Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED");
        iv.setImageDrawable(drwStart);
        llTimePicker.setVisibility(View.VISIBLE);
        anim.setRepeatCount(0);

        ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem());

        String sSubjectId = as.getId_subject();
        double dLat = as.getLocation_latitude();
        double dLong = as.getLocation_longitude();
        long lCheckOut = new Date().getTime();
        long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut();

        // Save data into both databases
        DateUtils du = new DateUtils();
        Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / "
                + du.duration(lCheckIn, lCheckOut));

        // TODO make some control here to make this transactional
        // Save in backend
        recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong,
                ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS);
        // Save in local database
        recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong);

        TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration);
        tvDuration.setText(
                du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId)));

        Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut),
                Toast.LENGTH_SHORT).show();

        //
        // Update history layout
        //

        LayoutInflater inflater = LayoutInflater.from(this);
        LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null);
        LinearLayout liContent = (LinearLayout) llParent.getChildAt(0);

        //           ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart);
        //           ivParent.setImageResource(R.drawable.rec_50x);

        //TextView tvTimeStamp = (TextView) liContent.getChildAt(1);    
        TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
        tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn));
        tvTimeStamp.setTag(Long.valueOf(lCheckIn));

        TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
        tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]");
        // Passing subject id as parameter        
        tvDurRecord.setTag(sSubjectId);

        LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory);
        // Set index number so that the record can be removed
        int iTag = (llHistory.getChildCount() - 1) / 2;
        llParent.setTag(iTag);

        llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1);
        llHistory.addView(llParent, 2);

    }
    tvRecording.startAnimation(anim);
    ivRecording.startAnimation(anim);

    Log.d(CLASSNAME,
            "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString());

}

From source file:com.qddagu.app.meetreader.ui.MainActivity.java

private void initView() {

    final LinearLayout ll = (LinearLayout) findViewById(R.id.bottom_bar);

    mPagerAdapter = new MainPagerAdapter(this, mFragmentManager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override//from   w w  w .  j  a  v a2s  .  co  m
        public void onPageSelected(int arg0) {
            for (int i = 0; i < ll.getChildCount(); i++) {
                ll.getChildAt(i).setSelected(false);
            }
            int i = arg0 < 2 ? arg0 : arg0 + 1;
            ll.getChildAt(i).setSelected(true);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });

    View.OnClickListener cl = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.getId() == R.id.btn_scan) {
                Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
                startActivityForResult(intent, 0);
                return;
            }

            for (int i = 0; i < ll.getChildCount(); i++) {
                ll.getChildAt(i).setSelected(false);
            }
            v.setSelected(true);

            switch (v.getId()) {
            case R.id.btn_home:
                mViewPager.setCurrentItem(0, false);
                break;
            case R.id.btn_cloud:
                mViewPager.setCurrentItem(1, false);
                break;
            case R.id.btn_scan:
                Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
                startActivityForResult(intent, 0);
                break;
            case R.id.btn_notice:
                mViewPager.setCurrentItem(2, false);
                break;
            case R.id.btn_more:
                mViewPager.setCurrentItem(3, false);
                break;
            }
        }
    };
    findViewById(R.id.btn_home).setSelected(true);
    findViewById(R.id.btn_home).setOnClickListener(cl);
    findViewById(R.id.btn_more).setOnClickListener(cl);
    findViewById(R.id.btn_scan).setOnClickListener(cl);
    findViewById(R.id.btn_cloud).setOnClickListener(cl);
    findViewById(R.id.btn_notice).setOnClickListener(cl);
}

From source file:org.fdroid.fdroid.privileged.views.AppSecurityPermissions.java

public View getPermissionsView(int which) {
    LinearLayout permsView = (LinearLayout) inflater.inflate(R.layout.app_perms_summary, null);
    LinearLayout displayList = (LinearLayout) permsView.findViewById(R.id.perms_list);
    View noPermsView = permsView.findViewById(R.id.no_permissions);

    displayPermissions(permGroupsList, displayList, which);
    if (displayList.getChildCount() <= 0) {
        noPermsView.setVisibility(View.VISIBLE);
    }//w  w  w.  j  a v  a2  s . c  o m

    return permsView;
}

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 ww w. j a  v a 2 s . c  o m

    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:ru.moscow.tuzlukov.sergey.weatherlog.MainActivity.java

private void makePlot(double minTemp, double maxTemp) {
    //all graphics should have a room, to be visible in plot viewport, i.e. max from greatest and min from the least ordinates:
    double lowLimit = Math.min(Math.round(minTemp), temperatureLimit2);
    double highLimit = Math.max(Math.round(maxTemp), temperatureLimit1);
    //round for drawing scale with 5-degrees step:
    lowLimit = Math.floor(lowLimit / 5.0) * 5.0;
    highLimit = Math.ceil(highLimit / 5.0) * 5.0;

    //fill in the plot with all data series:
    List<DataPoint> dataPoints = new ArrayList<>();
    for (Long time : temperatureMap.keySet())
        dataPoints.add(new DataPoint(time, temperatureMap.get(time)));
    dataPoints.add(new DataPoint(currentTime, dataPoints.get(dataPoints.size() - 1).getY())); //fix for using data from cache
    LineGraphSeries<DataPoint> temperatureSeries = new LineGraphSeries<>(
            dataPoints.toArray(new DataPoint[dataPoints.size()]));
    LineGraphSeries<DataPoint> temperatureLimit1Series = new LineGraphSeries<>(
            new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit1),
                    new DataPoint(currentTime, temperatureLimit1) });
    LineGraphSeries<DataPoint> temperatureLimit2Series = new LineGraphSeries<>(
            new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit2),
                    new DataPoint(currentTime, temperatureLimit2) });
    graphView.addSeries(temperatureSeries);
    graphView.addSeries(temperatureLimit1Series);
    graphView.addSeries(temperatureLimit2Series);

    //lay out the plot:
    GridLabelRenderer gridLabelRenderer = graphView.getGridLabelRenderer();
    Viewport viewport = graphView.getViewport();
    //adjust grid settings:
    gridLabelRenderer.setGridStyle(GridLabelRenderer.GridStyle.BOTH);
    gridLabelRenderer.setHighlightZeroLines(true);
    gridLabelRenderer.setHorizontalLabelsVisible(false);
    gridLabelRenderer.setVerticalLabelsVisible(true);
    //tune view of lines:
    viewport.setBackgroundColor(getResources().getColor(R.color.plot_viewport_background_color));
    temperatureSeries.setColor(getResources().getColor(R.color.temperature_series_color));
    temperatureSeries.setThickness(2);//ww w.  j a  va2 s.  c  o m
    temperatureLimit1Series.setColor(getResources().getColor(R.color.limit1_series_color));
    temperatureLimit1Series.setThickness(2);
    temperatureLimit2Series.setColor(getResources().getColor(R.color.limit2_series_color));
    temperatureLimit2Series.setThickness(2);
    //set viewport bounds and set the scale:
    //...in horizontal:
    gridLabelRenderer.setNumHorizontalLabels(2);
    viewport.setMinX(currentTimeMinus24h);
    viewport.setMaxX(currentTime);
    viewport.setXAxisBoundsManual(true);
    //...in vertical:
    int numVerticalLabels = (int) (highLimit - lowLimit) / 5 + 1;
    numVerticalLabels = numVerticalLabels < 2 ? 2 : numVerticalLabels;
    gridLabelRenderer.setNumVerticalLabels(numVerticalLabels);
    viewport.setMinY(lowLimit);
    viewport.setMaxY(highLimit);
    viewport.setYAxisBoundsManual(true);
    //set horizontal labels:
    LinearLayout llHorizontalLabels = (LinearLayout) findViewById(R.id.llHorizontalLabels);
    if (llHorizontalLabels.getChildCount() == 0) {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llHorizontalLabels.getLayoutParams();
        params.bottomMargin = 0;
        llHorizontalLabels.setLayoutParams(params);
        gridLabelRenderer.setTextSize(gridLabelRenderer.getTextSize() - 2); //make text a bit smaller
        for (int n = -24; n < 0; n += 3) {
            TextView textView = new TextView(MainActivity.this);
            textView.setText(String.valueOf(n));
            textView.setGravity(Gravity.START);
            textView.setSingleLine();
            params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f / 8.0f);
            textView.setLayoutParams(params);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize());
            textView.setTextColor(gridLabelRenderer.getVerticalLabelsColor());
            llHorizontalLabels.addView(textView);
        }
        TextView tvZeroLabel = (TextView) findViewById(R.id.tvZeroLabel);
        tvZeroLabel.setText("-0 " + getString(R.string.hours_caption));
        tvZeroLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize());
        tvZeroLabel.setTextColor(gridLabelRenderer.getVerticalLabelsColor());
        tvZeroLabel.setVisibility(View.VISIBLE);
        gridLabelRenderer.setPadding(gridLabelRenderer.getPadding() + 2); //make plot a bit smaller
    }
}

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

/**
 * Set long click listeners for tabs editing
 */// ww  w  . j av a2 s  . c  o m
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:org.zywx.wbpalmstar.plugin.inputtextfieldview.ACEInputTextFieldView.java

private void updateCurrentPage(int index, LinearLayout layout) {
    for (int i = 0; i < layout.getChildCount(); i++) {
        View view = layout.getChildAt(i);
        if (i == index) {
            view.setBackgroundResource(CRes.plugin_inputtextfieldview_pages_pointer_focus);
        } else {//from   w  w w.j  ava 2  s.  com
            view.setBackgroundResource(CRes.plugin_inputtextfieldview_pages_pointer_normal);
        }
    }
}