List of usage examples for android.widget LinearLayout getChildAt
public View getChildAt(int index)
From source file:org.catrobat.catroid.ui.fragment.FormulaEditorFragment.java
@Override public void onStart() { formulaEditorKeyboard.setClickable(true); formulaEditorFieldDeleteButton.setClickable(true); getView().requestFocus();// w w w .ja v a2 s.c o m 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.cairoconfessions.MainActivity.java
public void onNavigationDrawerItemSelected(int position) { LinearLayout confessions = (LinearLayout) findViewById(R.id.confession_list); switch (position) { case 0:/*from w ww.ja v a 2 s .c o m*/ mTitle = "Cairo Confessions"; for (int i = 0; i < confessions.getChildCount(); i++) if (((TextView) confessions.getChildAt(i).findViewById(R.id.follow_button)).getText() .equals("Follow")) confessions.getChildAt(i).setVisibility(View.VISIBLE); updateFilters(); break; case 1: mTitle = getString(R.string.title_section1); break; case 2: mTitle = getString(R.string.title_section2); for (int i = 0; i < confessions.getChildCount(); i++) if (((TextView) confessions.getChildAt(i).findViewById(R.id.follow_button)).getText() .equals("Follow")) confessions.getChildAt(i).setVisibility(View.GONE); updateFilters(); break; case 3: mTitle = getString(R.string.title_section3); getMessages(); break; case 4: getSettings(); break; } }
From source file:com.ht.app.RestaurantsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); mMenu = menu;/*from w ww. j a v a 2s. co m*/ MenuItem searchMenuItem = (MenuItem) menu.findItem(R.id.action_search); MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { // mToolbar.setIcon(android.R.color.transparent); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { return true; } }); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search)); // Assumes current activity is the searchable activity mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default // Style search widget and suggestion list LinearLayout linearLayout1 = (LinearLayout) mSearchView.getChildAt(0); LinearLayout linearLayout2 = (LinearLayout) linearLayout1.getChildAt(2); LinearLayout linearLayout3 = (LinearLayout) linearLayout2.getChildAt(1); AutoCompleteTextView autoComplete = (AutoCompleteTextView) linearLayout3.getChildAt(0); autoComplete.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { hideSearchWidget(); } } }); autoComplete.setTextColor(Color.WHITE); autoComplete.setHintTextColor(Color.WHITE); autoComplete.setDropDownBackgroundResource(R.color.app_red_color); return true; }
From source file:de.azapps.mirakel.new_ui.dialogs.PriorityDialog.java
@Nullable @Override/* w w w . j av a 2 s. c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout v = (LinearLayout) inflater.inflate(R.layout.priority_dialog, null); ButterKnife.inject(v); if (initialPriority.isPresent()) { final @IdRes int checkedID; switch (initialPriority.get()) { case -1: case -2: checkedID = R.id.wrapper_priority_low; break; case 1: checkedID = R.id.wrapper_priority_high; break; case 2: checkedID = R.id.wrapper_priority_veryhigh; break; case 0: default: checkedID = R.id.wrapper_priority_normal; break; } ((RadioButton) v.findViewById(checkedID).findViewById(R.id.radio_priority)).setChecked(true); } for (int i = 0; i < v.getChildCount(); i++) { v.getChildAt(i).setOnClickListener(this); } return v; }
From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java
/** * Enable again the commands and menu buttons after sending all the movements to the robot *//*from ww w. j av a 2 s .c om*/ private void enableControllerButtons() { GridLayout controlsLayout = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container); for (int i = 0; i < controlsLayout.getChildCount(); i++) { controlsLayout.getChildAt(i).setEnabled(true); } ((ProgressBar) getActivity().findViewById(R.id.progress_bar)).setVisibility(View.GONE); LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container); for (int i = 0; i < optionsLayout.getChildCount(); i++) { optionsLayout.getChildAt(i).setEnabled(true); } gridView.setEnabled(true); }
From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java
/** * Disable the commands and menu buttons when the app is sending the movements to the robot *//*ww w . j a v a2 s . c om*/ private void disableControllerButtons() { GridLayout controlsViews = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container); for (int i = 0; i < controlsViews.getChildCount(); i++) { controlsViews.getChildAt(i).setEnabled(false); } LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container); for (int i = 0; i < optionsLayout.getChildCount(); i++) { optionsLayout.getChildAt(i).setEnabled(false); } ((ProgressBar) getActivity().findViewById(R.id.progress_bar)).setVisibility(View.VISIBLE); gridView.setEnabled(false); }
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 . ja v a 2 s.co m for (int i = 0; i < childCount; i++) { tv = (CheckableLinearLayout) parent.getChildAt(i); checkedItems.append(i, tv.isChecked()); } return checkedItems; }
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;//w w w.ja va2 s . com 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.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java
/** * Set the listeners to the views that need them. It must be done here in the fragment in order * to get the callback here and not in the FragmentActivity, that would be a mess with all the * callbacks of all the possible fragments *///from w ww . j a va 2 s . c o m private void setUiListeners() { gridView.setOnRearrangeListener(new OnRearrangeListener() { public void onRearrange(int oldIndex, int newIndex) { if (scheduledControls.isEmpty()) { return; } String scheduledControl = scheduledControls.remove(oldIndex); if (oldIndex < newIndex) scheduledControls.add(newIndex, scheduledControl); else scheduledControls.add(newIndex, scheduledControl); } public void onRearrange(boolean isDraggedDeleted, int draggedDeletedIndex) { if (scheduledControls.isEmpty()) { return; } if (isDraggedDeleted) { scheduledControls.remove(draggedDeletedIndex); } } }); GridLayout movementsViews = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container); for (int i = 0; i < movementsViews.getChildCount(); i++) { movementsViews.getChildAt(i).setOnClickListener(onMovementsButtonClick); } LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container); for (int i = 0; i < optionsLayout.getChildCount(); i++) { optionsLayout.getChildAt(i).setOnClickListener(onOptionsButtonClick); } // Resize the GridLayout depending on the number of icons (depending on the current robot // selected). In order not to get too much number of columns in little screen, it is limited // to two and scroll the screen if there are more icons. If scroll is not needed the icons // are centered in the layout final GridLayout typeOfMovementsContainer = (GridLayout) getActivity() .findViewById(R.id.type_of_movements_container); final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver(); final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { Rect scrollBounds = new Rect(); ScrollView scroll = (ScrollView) getActivity().findViewById(R.id.scroll_container); scroll.getDrawingRect(scrollBounds); // int finalHeight = scrollBounds.bottom - getActivity().getResources().getDimensionPixelSize(R.dimen.scheduler_grid_margin); int finalHeight = scrollBounds.bottom; int childCount = typeOfMovementsContainer.getChildCount(); if (childCount > 1) { for (int i = 0; i < childCount; i++) { if (typeOfMovementsContainer.getChildAt(i).getBottom() > finalHeight) { typeOfMovementsContainer.setColumnCount(2); break; } } } scroll.invalidate(); final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver(); vto.removeOnPreDrawListener(this); return true; } }; vto.addOnPreDrawListener(preDrawListener); }
From source file:com.retroteam.studio.retrostudio.EditorLandscape.java
/** * Iterate through all the measures and return a list of measure tag group objects. * The list is serialized out to the .retro project file. * @return ArrayList<MeasureTagGroup> *//*from ww w .j a va 2 s. c o m*/ private ArrayList<MeasureTagGroup> getMeasureTags() { ArrayList<MeasureTagGroup> mtaglist = new ArrayList<>(); LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout); //iterate through all the measures for (int t = 0; t < track_layout.getChildCount(); t++) { //get hscrollview HorizontalScrollView hchild = (HorizontalScrollView) track_layout.getChildAt(t); for (int h = 0; h < hchild.getChildCount(); h++) { //get gridlayout GridLayout gchild = (GridLayout) hchild.getChildAt(h); for (int g = 0; g < gchild.getChildCount(); g++) { //get measure if (gchild.getChildAt(g) instanceof ImageView) { ImageView ivchild = (ImageView) gchild.getChildAt(g); Drawable measureFill = ivchild.getDrawable(); if (measureFill.getConstantState() .equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.measure_new_empty) .getConstantState())) { mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW), (int) ivchild.getTag(R.id.TAG_COLUMN), false, (int) ivchild.getTag(R.id.TAG_GUISNAP), (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES))); } else if (measureFill.getConstantState() .equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.measure_new_filled) .getConstantState())) { mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW), (int) ivchild.getTag(R.id.TAG_COLUMN), true, (int) ivchild.getTag(R.id.TAG_GUISNAP), (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES))); } } } } } return mtaglist; }