List of usage examples for android.widget LinearLayout getChildAt
public View getChildAt(int index)
From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java
/************************************************************************************ * needed because else the nested preference screen don't have a actionbar/toolbar * * see the fix and the given problem here: http://stackoverflow.com/a/27455363 * ************************************************************************************/ public void setUpNestedScreen(PreferenceScreen preferenceScreen) { final Dialog dialog = preferenceScreen.getDialog(); //ViewGroup list; Toolbar bar;/* w w w .j a v a2s.com*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //list = (ViewGroup) dialog.findViewById(android.R.id.list); LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); root.addView(bar, 0); // insert at top } else { ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content); ListView content = (ListView) root.getChildAt(0); //list = content; 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); } //list.addView(detailsPrefScreenToAdd.getStatusViewGroup(), 1); //TODO bar.setTitle(preferenceScreen.getTitle()); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogI) { if (AppData.getLoginSuccessful()) { dialogI.dismiss(); } else { showNotConnectedDialog(dialog); } } }); bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (AppData.getLoginSuccessful()) { dialog.dismiss(); } else { showNotConnectedDialog(dialog); } } }); }
From source file:hku.fyp14017.blencode.ui.fragment.FormulaEditorFragment.java
@Override public void onStart() { formulaEditorKeyboard.setClickable(true); formularEditorFieldDeleteButton.setClickable(true); getView().requestFocus();/*from w w w . j av a 2 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 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(); }
From source file:com.cairoconfessions.MainActivity.java
public void updateFilters() { 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 w w .j ava 2 s . c o m*/ if (!Categories.isEmpty() && !Cities.isEmpty()) { if (!Categories.contains(currDesc.getContentDescription()) && !Cities.contains(currLoc)) currDesc.setVisibility(View.GONE); if (Categories.contains(currDesc.getContentDescription()) && !Cities.contains(currLoc)) currDesc.setVisibility(View.GONE); if (!Categories.contains(currDesc.getContentDescription()) && Cities.contains(currLoc)) currDesc.setVisibility(View.GONE); if (Categories.contains(currDesc.getContentDescription()) && Cities.contains(currLoc)) if (mTitle.equals("Following")) { if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow")) currDesc.setVisibility(View.VISIBLE); } else currDesc.setVisibility(View.VISIBLE); } else if (Categories.isEmpty() && !Cities.isEmpty()) { if (!Cities.contains(currLoc)) currDesc.setVisibility(View.GONE); if (Cities.contains(currLoc)) { if (mTitle.equals("Following")) { if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow")) currDesc.setVisibility(View.VISIBLE); } else currDesc.setVisibility(View.VISIBLE); } } else if (!Categories.isEmpty() && Cities.isEmpty()) { if (!Categories.contains(currDesc.getContentDescription())) currDesc.setVisibility(View.GONE); if (Categories.contains(currDesc.getContentDescription())) { if (mTitle.equals("Following")) { if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow")) currDesc.setVisibility(View.VISIBLE); } else currDesc.setVisibility(View.VISIBLE); } } else if (Categories.isEmpty() && Cities.isEmpty()) { if (mTitle.equals("Following")) { if (((TextView) currDesc.findViewById(R.id.follow_button)).getText().equals("Unfollow")) currDesc.setVisibility(View.VISIBLE); } else currDesc.setVisibility(View.VISIBLE); } } }
From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java
private View recycleItemRow(View convertView, RowComputeResult rowInfo) { LinearLayout ll = (LinearLayout) convertView; int nbColumns = rowInfo.group.mDisplayCols; if (hasCustomGroupView()) { nbColumns = 1;/*from w w w .java 2 s. c o m*/ } for (int i = 0; i < nbColumns; i++) { View view = ll.getChildAt(i); View newView = getItemView(rowInfo, i, view, ll); if (view != newView) { setupLayoutParams(newView); ll.removeViewAt(i); ll.addView(newView, i); } } return ll; }
From source file:org.wheelmap.android.activity.MainMultiPaneActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { ActionBar bar = getSupportActionBar(); if (bar == null) { return true; }/*from w ww . j a v a 2 s . co m*/ LayoutInflater inflater = LayoutInflater.from(this); View customView = inflater.inflate(R.layout.actionbar_tablet, null); bar.setCustomView(customView, new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.END)); boolean isPortraitMode = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (isPortraitMode) { ImageView addItem = (ImageView) customView.findViewById(R.id.menu_new_poi); addItem.setVisibility(View.VISIBLE); OnClickListener addClickListener = new OnClickListener() { @Override public void onClick(View v) { createNewPoi(); } }; addItem.setOnClickListener(addClickListener); LinearLayout l = (LinearLayout) findViewById(R.id.actionbar_bottom); for (int i = 0; i < l.getChildCount(); i++) { l.getChildAt(i).setOnTouchListener(new PressSelector()); } bar.setDisplayShowCustomEnabled(true); View v = findViewById(R.id.menu_filter); MapActivityUtils.setAccessFilterOptionDrawable(this, null, v); View filterWc = findViewById(R.id.menu_wc); MapActivityUtils.setWcFilterOptionsDrawable(this, null, filterWc); UserCredentials credentials = new UserCredentials(getApplicationContext()); ImageView image = (ImageView) findViewById(R.id.menu_login); image.setImageResource( credentials.isLoggedIn() ? R.drawable.start_icon_logged_in : R.drawable.start_icon_login); } else { MenuInflater inflaterMenu = getMenuInflater(); inflaterMenu.inflate(R.menu.ab_multi_activity, menu); MenuItem item = menu.findItem(R.id.menu_filter); MapActivityUtils.setAccessFilterOptionDrawable(this, item, null); item = menu.findItem(R.id.menu_wc); MapActivityUtils.setWcFilterOptionsDrawable(this, item, null); } if (mapModeType == MapModeType.MAP_MODE_ENGAGE) { MenuItem itemFilterWheelChairs = menu.findItem(R.id.menu_filter); itemFilterWheelChairs.setEnabled(false); //TODO Disable it - doesn't work yet } ImageView listMapToggle = (ImageView) findViewById(R.id.switch_view); if (listMapToggle != null) { listMapToggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleMovableResize(); } }); } return true; }
From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { LinearLayout controlLayout = (LinearLayout) findViewById(R.id.controls_list); for (int i = 0; i < controlLayout.getChildCount(); i++) if (controlLayout.getChildAt(i) instanceof IControl) ((IControl) controlLayout.getChildAt(i)).saveState(outState); super.onSaveInstanceState(outState); }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Reset arrival layouts//w w w .ja v a2s . com * * @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.retroteam.studio.retrostudio.EditorLandscape.java
/** * Find a measure view object by its coordinates. * @param row//from www. j av a2s . c o m * @param column * @return */ private View findMeasureByCoords(int row, int column) { LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout); // HorizontalScrollView track_container = (HorizontalScrollView) track_layout.getChildAt(row + 1); GridLayout track = (GridLayout) track_container.getChildAt(0); int numChildren = track.getChildCount(); for (int i = 0; i < numChildren; i++) { View child = track.getChildAt(i); if (child.getTag(R.id.TAG_ROW) == row && child.getTag(R.id.TAG_COLUMN) == column) { return child; } } return null; }
From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java
protected void putSign() { LinearLayout layout = (LinearLayout) findViewById(R.id.controls_list); for (int i = 0; i < layout.getChildCount(); i++) { View child = layout.getChildAt(i); if (child instanceof Sign) { IGISApplication application = (IGISApplication) getApplication(); Uri uri = Uri.parse("content://" + application.getAuthority() + "/" + mLayer.getPath().getName() + "/" + mFeatureId + "/" + Constants.URI_ATTACH); ContentValues values = new ContentValues(); values.put(VectorLayer.ATTACH_DISPLAY_NAME, "_signature"); values.put(VectorLayer.ATTACH_DESCRIPTION, "_signature"); values.put(VectorLayer.ATTACH_MIME_TYPE, "image/jpeg"); Cursor saved = getContentResolver().query(uri, null, VectorLayer.ATTACH_ID + " = ?", new String[] { Sign.SIGN_FILE }, null); boolean hasSign = false; if (saved != null) { hasSign = saved.moveToFirst(); saved.close();// w w w. ja va2 s . c om } if (!hasSign) { Uri result = getContentResolver().insert(uri, values); if (result != null) { long id = Long.parseLong(result.getLastPathSegment()); values.clear(); values.put(VectorLayer.ATTACH_ID, Integer.MAX_VALUE); uri = Uri.withAppendedPath(uri, id + ""); getContentResolver().update(uri, values, null, null); } } File png = new File(mLayer.getPath(), mFeatureId + ""); Sign sign = (Sign) child; try { if (!png.isDirectory()) FileUtil.createDir(png); png = new File(png, Sign.SIGN_FILE); sign.save(sign.getWidth(), sign.getHeight(), true, png); } catch (IOException | RuntimeException e) { e.printStackTrace(); } } } }
From source file:com.cssweb.android.base.QuoteGridActivity.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; // int l = this.residSelColor; localView1.setBackgroundResource(l); }//from ww w .j av 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); } 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; this.cssStock = list.get(paramInt - 1); }