List of usage examples for android.widget LinearLayout getChildCount
public int getChildCount()
From source file:org.zywx.wbpalmstar.plugin.inputtextfieldview.ACEInputTextFieldView.java
private void initPagerIndicator(int pagerSize, LinearLayout layout) { int childCount = layout.getChildCount(); if (pagerSize == childCount) { return;//from ww w .j a v a 2 s .c om } int width = getResources().getDimensionPixelSize(CRes.plugin_inputtextfieldview_pager_indicator_width); int left = getResources().getDimensionPixelSize(CRes.plugin_inputtextfieldview_pager_indicator_left); int top = getResources().getDimensionPixelSize(CRes.plugin_inputtextfieldview_pager_indicator_top); LinearLayout.LayoutParams viewParams = new LinearLayout.LayoutParams(width, width); viewParams.setMargins(left, top, left, top); if (pagerSize > childCount) {// ? while (childCount < pagerSize) { ImageView imageView = new ImageView(this.getContext()); layout.addView(imageView, childCount, viewParams); childCount++; } } else { while (childCount > pagerSize) { layout.removeViewAt(childCount); childCount--; } } }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Reset arrival layouts//w ww . j a v a 2s . c o m * * @param station * the station */ private final void reset(final Station station) { Set<TrainLine> setTL = station.getLines(); for (TrainLine tl : setTL) { for (TrainDirection d : TrainDirection.values()) { Integer id = mIds.get(tl.toString() + "_" + d.toString()); if (id != null) { LinearLayout line3View = (LinearLayout) findViewById(id); if (line3View != null) { line3View.setVisibility(View.GONE); if (line3View.getChildCount() > 0) { for (int i = 0; i < line3View.getChildCount(); i++) { LinearLayout view = (LinearLayout) line3View.getChildAt(i); TextView timing = (TextView) view.getChildAt(1); if (timing != null) { timing.setText(""); } } } } } } } }
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); }//from w w w . ja v a 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); } 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.app.blockydemo.ui.fragment.FormulaEditorFragment.java
@Override public void onStart() { formulaEditorKeyboard.setClickable(true); formularEditorFieldDeleteButton.setClickable(true); getView().requestFocus();//from w w w . jav a2 s . c o 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.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 *//*w w w . j a v a 2 s . c o 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.google.samples.apps.iosched.ui.widget.CollectionView.java
private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) { ViewGroup groupView;//w w w . j a va2 s. c o m if (view != null && view instanceof ViewGroup) { groupView = (ViewGroup) view; // If there are more children in the recycled view we remove the extra ones. if (groupView.getChildAt(0) instanceof LinearLayout) { LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0); if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) { groupViewContent.removeViews(rowInfo.group.getRowCount(), groupViewContent.getChildCount() - rowInfo.group.getRowCount()); } } // Use the defined callbacks if the user has chosen to by implementing a // CardsCollectionViewCallbacks. } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) { groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks) .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent); // This should never happened but if it does we'll display an EmptyView. } else { LOGE(TAG, "Tried to create a group view but the callback is not an instance of " + "GroupCollectionViewCallbacks"); return new EmptyView(getContext()); } LinearLayout groupViewContent; if (groupView.getChildAt(0) instanceof LinearLayout) { groupViewContent = (LinearLayout) groupView.getChildAt(0); } else { groupViewContent = new LinearLayout(getContext()); groupViewContent.setOrientation(LinearLayout.VERTICAL); LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); groupViewContent.setLayoutParams(LLParams); groupView.addView(groupViewContent); } disableCustomGroupView(); for (int i = 0; i < rowInfo.group.getRowCount(); i++) { View itemView; try { itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent); } catch (Exception e) { // Recycling failed (maybe the items were not compatible) so we start again without // recycling. itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent); } if (itemView != groupViewContent.getChildAt(i)) { if (groupViewContent.getChildCount() > i) { groupViewContent.removeViewAt(i); } groupViewContent.addView(itemView, i); } } enableCustomGroupView(); return groupView; }
From source file:com.razza.apps.iosched.ui.widget.CollectionView.java
private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) { ViewGroup groupView;/*from www. j av a 2 s . c o m*/ if (view != null && view instanceof ViewGroup) { groupView = (ViewGroup) view; // If there are more children in the recycled view we remove the extra ones. if (groupView.getChildAt(0) instanceof LinearLayout) { LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0); if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) { groupViewContent.removeViews(rowInfo.group.getRowCount(), groupViewContent.getChildCount() - rowInfo.group.getRowCount()); } } // Use the defined callbacks if the user has chosen to by implementing a // CardsCollectionViewCallbacks. } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) { groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks) .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent); // This should never happened but if it does we'll display an EmptyView. } else { LogUtils.LOGE(TAG, "Tried to create a group view but the callback is not an instance of " + "GroupCollectionViewCallbacks"); return new EmptyView(getContext()); } LinearLayout groupViewContent; if (groupView.getChildAt(0) instanceof LinearLayout) { groupViewContent = (LinearLayout) groupView.getChildAt(0); } else { groupViewContent = new LinearLayout(getContext()); groupViewContent.setOrientation(LinearLayout.VERTICAL); LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); groupViewContent.setLayoutParams(LLParams); groupView.addView(groupViewContent); } disableCustomGroupView(); for (int i = 0; i < rowInfo.group.getRowCount(); i++) { View itemView; try { itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent); } catch (Exception e) { // Recycling failed (maybe the items were not compatible) so we start again without // recycling. itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent); } if (itemView != groupViewContent.getChildAt(i)) { if (groupViewContent.getChildCount() > i) { groupViewContent.removeViewAt(i); } groupViewContent.addView(itemView, i); } } enableCustomGroupView(); return groupView; }
From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java
/** Called when the activity is first created. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//w w w.j a v a 2s . com public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate()"); super.onCreate(savedInstanceState); boolean needActionBar = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (!ViewConfiguration.get(this).hasPermanentMenuKey()) needActionBar = true; } else { needActionBar = true; } } if (needActionBar) { requestWindowFeature(Window.FEATURE_ACTION_BAR); } else { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // Force landscape-only. updateNativeDisplayParameters(); //Bundle extras = getIntent().getExtras(); //String baseFolderPath = extras.getString("baseFolderPath"); //int markerID = ARToolKit.getInstance().addMarker("multi;"+baseFolderPath +"/marker.dat"); setContentView(R.layout.main_video); mButton = (Button) findViewById(R.id.button_capture); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Toast.makeText(ARCloud.this, "Take picture", Toast.LENGTH_LONG).show(); LinearLayout linearLayoutResultWrapper = (LinearLayout) findViewById(R.id.result_wrapper); if (linearLayoutResultWrapper.getChildCount() > 0) { linearLayoutResultWrapper.removeViewAt(0); linearLayoutResultWrapper.removeAllViews(); } camSurface.getCamera().takePicture(null, null, mPicture); ; } }); ARMovieActivity.nativeCreate(this); }
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();/*from w ww. j av a 2 s .com*/ 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:hku.fyp14017.blencode.ui.fragment.FormulaEditorFragment.java
@Override public void onStart() { formulaEditorKeyboard.setClickable(true); formularEditorFieldDeleteButton.setClickable(true); getView().requestFocus();/*from www . j av a 2s.c o 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 hku.fyp14017.blencode.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 hku.fyp14017.blencode.R.id.formula_editor_keyboard_undo: formulaEditorEditText.undo(); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_redo: formulaEditorEditText.redo(); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_function: showFormulaEditorListFragment(FormulaEditorListFragment.FUNCTION_TAG, hku.fyp14017.blencode.R.string.formula_editor_function); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_logic: showFormulaEditorListFragment(FormulaEditorListFragment.LOGIC_TAG, hku.fyp14017.blencode.R.string.formula_editor_logic); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_object: showFormulaEditorListFragment(FormulaEditorListFragment.OBJECT_TAG, hku.fyp14017.blencode.R.string.formula_editor_choose_object_variable); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_sensors: showFormulaEditorListFragment(FormulaEditorListFragment.SENSOR_TAG, hku.fyp14017.blencode.R.string.formula_editor_sensors); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_variables: showFormulaEditorVariableListFragment(FormulaEditorVariableListFragment.VARIABLE_TAG, hku.fyp14017.blencode.R.string.formula_editor_variables); return true; case hku.fyp14017.blencode.R.id.formula_editor_keyboard_ok: endFormulaEditor(); return true; case hku.fyp14017.blencode.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); } } formularEditorFieldDeleteButton.setOnTouchListener(touchListener); updateButtonViewOnKeyboard(); super.onStart(); }