List of usage examples for android.widget LinearLayout getChildAt
public View getChildAt(int index)
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * This method dynamically reads all user inputted the values from the screen and puts into a * list// w w w . j av a2 s . co m * * @param serviceDescription displayed service description * @return List of attribute values */ private List<AttributeValue> createAttributeValues(ServiceDescription serviceDescription) { List<AttributeValue> values = new ArrayList<>(); if (serviceDescription == null) { return values; } for (Open311Attribute open311Attribute : serviceDescription.getAttributes()) { if (Boolean.valueOf(open311Attribute.getVariable())) { if (Open311DataType.STRING.equals(open311Attribute.getDatatype()) || Open311DataType.NUMBER.equals(open311Attribute.getDatatype()) || Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) { EditText et = (EditText) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (et != null) { AttributeValue value = new AttributeValue(open311Attribute.getCode()); value.addValue(et.getText().toString()); values.add(value); } } else if (Open311DataType.SINGLEVALUELIST.equals(open311Attribute.getDatatype())) { RadioGroup rg = (RadioGroup) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (rg != null) { int count = rg.getChildCount(); for (int i = 0; i < count; i++) { RadioButton rb = (RadioButton) rg.getChildAt(i); if (rb.isChecked()) { AttributeValue value = new AttributeValue(open311Attribute.getCode()); value.addValue(rb.getText().toString()); values.add(value); break; } } } } else if (Open311DataType.MULTIVALUELIST.equals(open311Attribute.getDatatype())) { LinearLayout ll = (LinearLayout) mDynamicAttributeUIMap.get(open311Attribute.getCode()); if (ll != null) { int count = ll.getChildCount(); AttributeValue value = new AttributeValue(open311Attribute.getCode()); for (int i = 0; i < count; i++) { CheckBox cb = (CheckBox) ll.getChildAt(i); if (cb.isChecked()) { value.addValue(cb.getText().toString()); } } if (value.getValues().size() > 0) values.add(value); } } } } return values; }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
/** * An incoming video media has an attached second image attachment used as preview for the encrypted video file. * To detect whether is is a video, we check the next attachment for the same message id and use this as the preview for the encrypted video. * To detect whether it is just the second of a video, we check for the same message id as the previous attachment. If yes, we hide it. * Not beautiful, but working...//from w w w.j ava 2 s .com */ private void setMediaHistoryImages() { String[] mediaHistoryUris = gDataPreferences .getMediaUriHistoryForId(GUtil.numberToLong(recipient.getNumber())); String[] mediaHistoryIds = gDataPreferences .getMediaMessageIdHistoryForContactId(GUtil.numberToLong(recipient.getNumber())); String lastMessageId = "noLastMessageId"; String nextMessageId = "nonextMessageId"; String currentMessageId = "nocurrentMessageId"; if (mediaHistoryUris.length > 0) { while (historyLayout.getChildCount() >= 1) { historyLayout.removeView(historyLayout.getChildAt(0)); } for (int i = 0; i < mediaHistoryUris.length; i++) { boolean isVideo = false; boolean wasVideo = false; nextMessageId = mediaHistoryIds.length > i + 1 ? mediaHistoryIds[i + 1] : "nonextMessageId"; currentMessageId = mediaHistoryIds.length > i ? mediaHistoryIds[i] : "nocurrentMessageId"; lastMessageId = i - 1 >= 0 ? mediaHistoryIds[i - 1] : "noLastMessageId"; if (nextMessageId.equals(currentMessageId)) { isVideo = true; } if (currentMessageId.equals(lastMessageId)) { wasVideo = true; } Slide mediaHistorySlide = ProfileAccessor.getSlideForUri(getActivity(), masterSecret, mediaHistoryUris[i], false); VideoSlide videoSlide = null; if (mediaHistoryIds.length > i + 1 && isVideo && !wasVideo) { Slide nextSlide = ProfileAccessor.getSlideForUri(getActivity(), masterSecret, mediaHistoryUris[i + 1], true); videoSlide = nextSlide instanceof VideoSlide ? (VideoSlide) nextSlide : null; } if (mediaHistorySlide != null && masterSecret != null && !(mediaHistorySlide.getUri() + "").equals("") && !wasVideo) { ThumbnailView historyMedia = new ThumbnailView(getActivity()); android.widget.LinearLayout.LayoutParams layoutParams = new android.widget.LinearLayout.LayoutParams( dpToPx(100), dpToPx(100)); historyMedia .setBackgroundColor(getResources().getColor(R.color.conversation_list_divider_light)); layoutParams.setMargins(5, 0, 5, 0); historyMedia.setLayoutParams(layoutParams); historyMedia.setSlide(mediaHistorySlide); historyMedia.setVideoSlide(videoSlide); ProfileAccessor.buildEncryptedPartGlideRequest(mediaHistorySlide, masterSecret, getActivity()) .into(historyMedia); historyLayout.addView(historyMedia); } } LinearLayout ll = ((LinearLayout) historyScrollView.getChildAt(0)); if (ll.getChildCount() > 0 && historyContentTextView != null && mediaHistoryUris != null && mediaHistoryUris.length > 0) { historyContentTextView.setVisibility(View.GONE); } for (int l = 0; l < ll.getChildCount(); l++) { ((ThumbnailView) ll.getChildAt(l)).setOnClickListener(mediaOnClickListener); } } }
From source file:foam.opensauces.StarwispBuilder.java
public String WalkDraggable(StarwispActivity ctx, String name, String ctxname, int id) { View v = ctx.findViewById(id); Class c = v.getClass();//from www .ja v a2 s .com String ret = "("; if (c == LinearLayout.class) { LinearLayout l = (LinearLayout) v; ret += m_Scheme.eval("(widget-callback \"" + ctxname + "\" " + id + " '())") + " "; for (int i = 0; i < l.getChildCount(); i++) { View cv = l.getChildAt(i); Class cc = cv.getClass(); if (cc == LinearLayout.class) { ret += WalkDraggable(ctx, name, ctxname, cv.getId()); } } } ret += ")"; return ret; }
From source file:fr.cph.chicago.core.activity.StationActivity.java
/** * Draw line/*from www . j a v a2 s. c om*/ * * @param eta the eta */ public void drawAllArrivalsTrain(@NonNull final Eta eta) { final TrainLine line = eta.getRouteName(); final Stop stop = eta.getStop(); final String key = line.toString() + "_" + stop.getDirection().toString(); // viewId might be not there if CTA API provide wrong data if (ids.containsKey(key)) { final int viewId = ids.get(key); final LinearLayout line3View = (LinearLayout) findViewById(viewId); final Integer id = ids .get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { final LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(paramsStop); final int newId = Util.generateViewId(); insideLayout.setId(newId); ids.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); final TextView stopName = new TextView(this); final String stopNameData = eta.getDestName() + ": "; stopName.setText(stopNameData); stopName.setTextColor(grey); stopName.setPadding(line3PaddingLeft, line3PaddingTop, 0, 0); insideLayout.addView(stopName); final TextView timing = new TextView(this); final String timingData = eta.getTimeLeftDueDelay() + " "; timing.setText(timingData); timing.setTextColor(grey); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { final LinearLayout insideLayout = (LinearLayout) findViewById(id); final TextView timing = (TextView) insideLayout.getChildAt(1); final String timingData = timing.getText() + eta.getTimeLeftDueDelay() + " "; timing.setText(timingData); } line3View.setVisibility(View.VISIBLE); } }
From source file:no.barentswatch.fiskinfo.BaseActivity.java
/** * This functions creates a dialog which allows the user to export different * map layers./* w ww. j a v a 2 s . co m*/ * * @param ActivityContext * The context of the current activity. * @return True if the export succeeded, false otherwise. */ public boolean exportMapLayerToUser(Context activityContext) { LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.dialog_export_metadata, (null)); Button downloadButton = (Button) view.findViewById(R.id.metadataDownloadButton); Button cancelButton = (Button) view.findViewById(R.id.cancel_button); final AlertDialog builder = new AlertDialog.Builder(activityContext).create(); builder.setTitle(R.string.map_export_metadata_title); builder.setView(view); final AtomicReference<String> selectedHeader = new AtomicReference<String>(); final AtomicReference<String> selectedFormat = new AtomicReference<String>(); final ExpandableListView expListView = (ExpandableListView) view .findViewById(R.id.exportMetadataMapServices); final List<String> listDataHeader = new ArrayList<String>(); final HashMap<String, List<String>> listDataChild = new HashMap<String, List<String>>(); final Map<String, String> nameToApiNameResolver = new HashMap<String, String>(); JSONArray availableSubscriptions = getSharedCacheOfAvailableSubscriptions(); if (availableSubscriptions == null) { availableSubscriptions = authenticatedGetRequestToBarentswatchAPIService( getString(R.string.my_page_geo_data_service)); setSharedCacheOfAvailableSubscriptions(availableSubscriptions); } for (int i = 0; i < availableSubscriptions.length(); i++) { try { JSONObject currentSub = availableSubscriptions.getJSONObject(i); nameToApiNameResolver.put(currentSub.getString("Name"), currentSub.getString("ApiName")); listDataHeader.add(currentSub.getString("Name")); List<String> availableDownloadFormatsOfCurrentLayer = new ArrayList<String>(); JSONArray availableFormats = currentSub.getJSONArray("Formats"); for (int j = 0; j < availableFormats.length(); j++) { availableDownloadFormatsOfCurrentLayer.add(availableFormats.getString(j)); } listDataChild.put(listDataHeader.get(i), availableDownloadFormatsOfCurrentLayer); System.out .println("item: " + currentSub.getString("Name") + ", " + currentSub.getString("ApiName")); } catch (JSONException e) { e.printStackTrace(); Log.d("ExportMapLAyerToUser", "Invalid JSON returned from API CALL"); return false; } } final ExpandableListAdapter listAdapter = new ExpandableListAdapter(activityContext, listDataHeader, listDataChild); expListView.setAdapter(listAdapter); // Listview on child click listener expListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { selectedHeader.set(nameToApiNameResolver.get(listDataHeader.get(groupPosition))); selectedHeader.set(listDataHeader.get(groupPosition)); selectedFormat.set(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition)); LinearLayout currentlySelected = (LinearLayout) parent.findViewWithTag("currentlySelectedRow"); if (currentlySelected != null) { currentlySelected.getChildAt(0).setBackgroundColor(Color.WHITE); currentlySelected.setTag(null); } ((LinearLayout) v).getChildAt(0).setBackgroundColor(Color.rgb(214, 214, 214)); v.setTag("currentlySelectedRow"); return true; } }); downloadButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DownloadMapLayerFromBarentswatchApiInBackground() .execute(nameToApiNameResolver.get(selectedHeader.get()), selectedFormat.get()); builder.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { builder.dismiss(); } }); builder.setCanceledOnTouchOutside(false); builder.show(); return true; }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Draw line//from w w w . j ava 2 s . c o m * * @param eta * the eta */ private final void drawLine3(final Eta eta) { TrainLine line = eta.getRouteName(); Stop stop = eta.getStop(); int line3Padding = (int) getResources().getDimension(R.dimen.activity_station_stops_line3); Integer viewId = mIds.get(line.toString() + "_" + stop.getDirection().toString()); // viewId might be not there if CTA API provide wrong data if (viewId != null) { LinearLayout line3View = (LinearLayout) findViewById(viewId); Integer id = mIds.get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(mParamsStop); int newId = Util.generateViewId(); insideLayout.setId(newId); mIds.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); TextView stopName = new TextView(this); stopName.setText(eta.getDestName() + ": "); stopName.setTextColor(getResources().getColor(R.color.grey)); stopName.setPadding(line3Padding, 0, 0, 0); insideLayout.addView(stopName); TextView timing = new TextView(this); timing.setText(eta.getTimeLeftDueDelay() + " "); timing.setTextColor(getResources().getColor(R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { LinearLayout insideLayout = (LinearLayout) findViewById(id); TextView timing = (TextView) insideLayout.getChildAt(1); timing.setText(timing.getText() + eta.getTimeLeftDueDelay() + " "); } line3View.setVisibility(View.VISIBLE); } }
From source file:info.tellmetime.TellmetimeActivity.java
private void resizeClock() { final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); // Set width of #mClock layout to the screen's shorter edge size, so clock is not // expanded in landscape mode, but has rather somewhat a square shape. RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.width = mShorterEdge;/*from w ww.j a v a2 s. c om*/ mClock.setLayoutParams(lp); final float mItemSize = mShorterEdge / mClock.getChildCount(); final int mRowMargin = (int) -(mItemSize / 2.2); // Scale text size according to shorter edge and set spacing between rows. for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); params.bottomMargin = mRowMargin; row.setLayoutParams(params); for (int j = 0; j < row.getChildCount(); j++) ((TextView) row.getChildAt(j)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize); } LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams(); params.bottomMargin = 0; lastRow.setLayoutParams(params); TextView twenty = (TextView) findViewById(R.id.twenty); params = (LinearLayout.LayoutParams) twenty.getLayoutParams(); params.leftMargin = 0; twenty.setLayoutParams(params); // Inflates minutes indicators and attaches them to main view. FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews(); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) ((TextView) minutesDots.getChildAt(i)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); }
From source file:com.fvd.nimbus.PaintActivity.java
void setToolSelected(int id) { LinearLayout ll = (LinearLayout) findViewById(R.id.flTools); for (int i = 0; i < ll.getChildCount(); i++) { ll.getChildAt(i).setSelected(id == ll.getChildAt(i).getId()); }// w ww. jav a 2 s . co m }
From source file:com.fvd.nimbus.PaintActivity.java
void setLandToolSelected(int id) { LinearLayout ll = (LinearLayout) findViewById(R.id.tool_edit_land); for (int i = 0; i < ll.getChildCount(); i++) { ll.getChildAt(i).setSelected(id == ll.getChildAt(i).getId()); }/* ww w .j a v a2 s. co m*/ }
From source file:com.sdspikes.fireworks.FireworksActivity.java
private void displayInitialState() { switchToScreen(R.id.screen_game);/*w w w.j av a2s . co m*/ GameState.HandNode currentNode = mTurnData.state.hands.get(mMyId); FragmentManager fm = getFragmentManager(); fragments = new HashMap<>(); if (fm.findFragmentById(R.id.my_hand) == null) { if (currentNode != null) { addHandFragment(fm, currentNode, mMyId, mIdToName.get(mMyId), R.id.my_hand); } else { Log.d(TAG, mMyId); } } if (fm.findFragmentById(R.id.other_hands) == null) { while (true) { String currentId = currentNode.nextPlayerId; if (currentId.equals(mMyId)) { break; } currentNode = mTurnData.state.hands.get(currentId); addHandFragment(fm, currentNode, currentId, mIdToName.get(currentId), R.id.other_hands); } } LinearLayout played = (LinearLayout) findViewById(R.id.played_pile); played.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { LinearLayout played = (LinearLayout) findViewById(R.id.played_pile); mDiscardWidthR2 = played.getMeasuredWidth(); if (mDiscardWidthR2 != 0) { int usableWidth = mDiscardWidthR2 - findViewById(R.id.played_label).getMeasuredWidth(); mDiscardWidthR1 = mDiscardWidthR2 - findViewById(R.id.discarded_label).getMeasuredWidth(); for (int i = 1; i < played.getChildCount(); i++) { ViewGroup.LayoutParams params = played.getChildAt(i).getLayoutParams(); params.width = usableWidth / 5; played.getChildAt(i).setLayoutParams(params); } played.getViewTreeObserver().removeOnGlobalLayoutListener(this); LinearLayout chooseAttribute = (LinearLayout) findViewById(R.id.chooseAttribute); for (int i = 1; i <= 5; i++) { chooseAttribute.addView(makeAttributeTextView(i, null)); } for (GameState.CardColor color : GameState.CardColor.values()) { chooseAttribute.addView(makeAttributeTextView(-1, color)); } // In case all the data is ready already and was just waiting on this. updateDisplay(); } } }); createInitialLog(); ((TextView) findViewById(R.id.log)).setMovementMethod(new ScrollingMovementMethod()); }