List of usage examples for android.widget LinearLayout setId
public void setId(@IdRes int id)
From source file:org.dvbviewer.controller.ui.base.BaseListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * /*from w ww .j a va2 s . c om*/ * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. * * @param inflater the inflater * @param container the container * @param savedInstanceState the saved instance state * @return the view * @author RayBa * @date 07.04.2013 */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); if (layoutRessource > 0) { View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null); return v; } else { FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyle); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; } }
From source file:org.mdc.chess.SeekBarPreference.java
@Override protected View onCreateView(ViewGroup parent) { TextView name = new TextView(getContext()); name.setText(getTitle());/* w w w. j a v a 2 s .co m*/ //name.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); TextViewCompat.setTextAppearance(name, android.R.style.TextAppearance_Large); name.setGravity(Gravity.START); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.START; lp.weight = 1.0f; name.setLayoutParams(lp); currValBox = new TextView(getContext()); currValBox.setTextSize(12); currValBox.setTypeface(Typeface.MONOSPACE, Typeface.ITALIC); currValBox.setPadding(2, 5, 0, 0); currValBox.setText(valToString()); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER; currValBox.setLayoutParams(lp); LinearLayout row1 = new LinearLayout(getContext()); row1.setOrientation(LinearLayout.HORIZONTAL); row1.addView(name); row1.addView(currValBox); final SeekBar bar = new SeekBar(getContext()); bar.setMax(maxValue); bar.setProgress(currVal); bar.setOnSeekBarChangeListener(this); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.END; bar.setLayoutParams(lp); CharSequence summaryCharSeq = getSummary(); boolean haveSummary = (summaryCharSeq != null) && (summaryCharSeq.length() > 0); TextView summary = null; if (haveSummary) { summary = new TextView(getContext()); summary.setText(getSummary()); // summary.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); summary.setGravity(Gravity.START); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.START; lp.weight = 1.0f; summary.setLayoutParams(lp); } LinearLayout layout = new LinearLayout(getContext()); layout.setPadding(25, 5, 25, 5); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(row1); layout.addView(bar); if (summary != null) { layout.addView(summary); } layout.setId(android.R.id.widget_frame); currValBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View content = View.inflate(SeekBarPreference.this.getContext(), R.layout.select_percentage, null); final AlertDialog.Builder builder = new AlertDialog.Builder(SeekBarPreference.this.getContext()); builder.setView(content); String title = ""; String key = getKey(); if (key.equals("strength")) { title = getContext().getString(R.string.edit_strength); } else if (key.equals("bookRandom")) { title = getContext().getString(R.string.edit_randomization); } builder.setTitle(title); final EditText valueView = (EditText) content.findViewById(R.id.selpercentage_number); valueView.setText(currValBox.getText().toString().replaceAll("%", "").replaceAll(",", ".")); final Runnable selectValue = new Runnable() { public void run() { try { String txt = valueView.getText().toString(); int value = (int) (Double.parseDouble(txt) * 10 + 0.5); if (value < 0) value = 0; if (value > maxValue) value = maxValue; onProgressChanged(bar, value, false); } catch (NumberFormatException ignored) { } } }; valueView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { selectValue.run(); return true; } return false; } }); builder.setPositiveButton("Ok", new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { selectValue.run(); } }); builder.setNegativeButton("Cancel", null); builder.create().show(); } }); return layout; }
From source file:BannerListView.java
/** * this method take supported fragment and fragment activity to add that * fragment as a banner to listView it create a layout at runtime then when * view is added to list we replace it with fragment otherwise it will crash * since view is not on screen to be replaced * // w ww . j a v a2s .co m * @param fragment * @param activity */ public void addBannerFragment(final Fragment fragment, final FragmentActivity activity) { LinearLayout layout = new LinearLayout(activity); AbsListView.LayoutParams param = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layout.setLayoutParams(param); layout.setId(CONTAINER_ID); addLayoutContainer(layout); this.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { BannerListView.this.removeOnLayoutChangeListener(this); FragmentManager manager = activity.getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(CONTAINER_ID, fragment).commit(); } }); }
From source file:fr.cph.chicago.core.activity.StationActivity.java
/** * Draw line//from ww w . j av a 2s. 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:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *//*from w ww . j a va2 s. c o m*/ private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
From source file:fr.cph.chicago.core.activity.StationActivity.java
@SuppressWarnings("unchecked") private void setUpStopLayouts(@NonNull final Map<TrainLine, List<Stop>> stopByLines) { Stream.of(stopByLines.entrySet()).forEach(entry -> { final TrainLine line = entry.getKey(); final List<Stop> stops = entry.getValue(); final View lineTitleView = getLayoutInflater().inflate(R.layout.activity_station_line_title, viewGroup, false);//from ww w .jav a2s. c om final TextView testView = (TextView) lineTitleView.findViewById(R.id.train_line_title); testView.setText(line.toStringWithLine()); testView.setBackgroundColor(line.getColor()); if (line == TrainLine.YELLOW) { testView.setBackgroundColor(yellowLine); } stopsView.addView(lineTitleView); Stream.of(stops).sorted().forEach(stop -> { final LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setLayoutParams(paramsStop); final AppCompatCheckBox checkBox = new AppCompatCheckBox(this); checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> Preferences .saveTrainFilter(getApplicationContext(), stationId, line, stop.getDirection(), isChecked)); checkBox.setOnClickListener(v -> { if (checkBox.isChecked()) { trainArrivalObservable.subscribe(new SubscriberTrainArrival(this, swipeRefreshLayout)); } }); checkBox.setChecked( Preferences.getTrainFilter(getApplicationContext(), stationId, line, stop.getDirection())); checkBox.setTypeface(checkBox.getTypeface(), Typeface.BOLD); checkBox.setText(stop.getDirection().toString()); checkBox.setTextColor(grey); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkBox.setBackgroundTintList(ColorStateList.valueOf(line.getColor())); checkBox.setButtonTintList(ColorStateList.valueOf(line.getColor())); if (line == TrainLine.YELLOW) { checkBox.setBackgroundTintList(ColorStateList.valueOf(yellowLine)); checkBox.setButtonTintList(ColorStateList.valueOf(yellowLine)); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { checkBox.setForegroundTintList(ColorStateList.valueOf(line.getColor())); if (line == TrainLine.YELLOW) { checkBox.setForegroundTintList(ColorStateList.valueOf(yellowLine)); } } linearLayout.addView(checkBox); final LinearLayout arrivalTrainsLayout = new LinearLayout(this); arrivalTrainsLayout.setOrientation(LinearLayout.VERTICAL); arrivalTrainsLayout.setLayoutParams(paramsStop); int id = Util.generateViewId(); arrivalTrainsLayout.setId(id); ids.put(line.toString() + "_" + stop.getDirection().toString(), id); linearLayout.addView(arrivalTrainsLayout); stopsView.addView(linearLayout); }); }); }
From source file:com.example.damerap_ver1.IntroVideoActivity.java
/** * Create the view in which the video will be rendered. *//* w ww.j a v a 2 s.c o m*/ private void setupView() { LinearLayout lLinLayout = new LinearLayout(this); lLinLayout.setId(1); lLinLayout.setOrientation(LinearLayout.VERTICAL); lLinLayout.setGravity(Gravity.CENTER); lLinLayout.setBackgroundColor(Color.BLACK); LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lLinLayout.setLayoutParams(lLinLayoutParms); this.setContentView(lLinLayout); RelativeLayout lRelLayout = new RelativeLayout(this); lRelLayout.setId(2); lRelLayout.setGravity(Gravity.CENTER); lRelLayout.setBackgroundColor(Color.BLACK); android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lRelLayout.setLayoutParams(lRelLayoutParms); lLinLayout.addView(lRelLayout); mVideoView = new VideoView(this); mVideoView.setId(3); android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lVidViewLayoutParams); lRelLayout.addView(mVideoView); mProgressBar = new ProgressBar(this); mProgressBar.setId(4); android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar.setLayoutParams(lProgressBarLayoutParms); lRelLayout.addView(mProgressBar); mProgressMessage = new TextView(this); mProgressMessage.setId(5); android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL); lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4); mProgressMessage.setLayoutParams(lProgressMsgLayoutParms); mProgressMessage.setTextColor(Color.LTGRAY); mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8); mProgressMessage.setText("..."); lRelLayout.addView(mProgressMessage); }
From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java
private View handleBuses(final int position, @NonNull final ViewGroup parent) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View convertView = vi.inflate(R.layout.list_nearby, parent, false); // Bus// w w w . j av a2s . c om final int index = position - stations.size(); final BusStop busStop = busStops.get(index); final ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); imageView.setImageDrawable( ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directions_bus_white_24dp)); final TextView routeView = (TextView) convertView.findViewById(R.id.station_name); routeView.setText(busStop.getName()); final LinearLayout resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results); final Map<String, List<BusArrival>> arrivalsForStop = busArrivals.get(busStop.getId(), new HashMap<>()); Stream.of(arrivalsForStop.entrySet()).forEach(entry -> { final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout insideLayout = new RelativeLayout(context); insideLayout.setLayoutParams(leftParam); insideLayout.setPadding(line1PaddingColor * 2, stopsPaddingTop, 0, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { insideLayout.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.any_selector)); } final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams stopParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); stopParam.addRule(RelativeLayout.RIGHT_OF, lineId); stopParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final LinearLayout stopLayout = new LinearLayout(context); stopLayout.setOrientation(LinearLayout.VERTICAL); stopLayout.setLayoutParams(stopParam); int stopId = Util.generateViewId(); stopLayout.setId(stopId); final RelativeLayout.LayoutParams boundParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); boundParam.addRule(RelativeLayout.RIGHT_OF, stopId); final LinearLayout boundLayout = new LinearLayout(context); boundLayout.setOrientation(LinearLayout.HORIZONTAL); final String direction = entry.getKey(); final List<BusArrival> busArrivals = entry.getValue(); final String routeId = busArrivals.get(0).getRouteId(); final TextView bound = new TextView(context); final String routeIdText = routeId + " (" + direction + "): "; bound.setText(routeIdText); bound.setTextColor(ContextCompat.getColor(context, R.color.grey_5)); boundLayout.addView(bound); Stream.of(busArrivals).forEach(busArrival -> { final TextView timeView = new TextView(context); final String timeLeftDueDelay = busArrival.getTimeLeftDueDelay() + " "; timeView.setText(timeLeftDueDelay); timeView.setTextColor(ContextCompat.getColor(context, R.color.grey)); timeView.setLines(1); timeView.setEllipsize(TruncateAt.END); boundLayout.addView(timeView); }); stopLayout.addView(boundLayout); insideLayout.addView(lineIndication); insideLayout.addView(stopLayout); resultLayout.addView(insideLayout); }); convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, busStop.getId(), busStop.getPosition().getLatitude(), busStop.getPosition().getLongitude())); return convertView; }
From source file:com.google.sample.beaconservice.ManageBeaconFragment.java
private LinearLayout makeAttachmentRow(JSONObject attachment) throws JSONException { LinearLayout row = new LinearLayout(getActivity()); int id = View.generateViewId(); row.setId(id); String[] namespacedType = attachment.getString("namespacedType").split("/"); row.addView(makeTextView(namespacedType[0])); row.addView(makeTextView(namespacedType[1])); String dataStr = attachment.getString("data"); String base64Decoded = new String(Utils.base64Decode(dataStr)); row.addView(makeTextView(base64Decoded)); row.addView(createAttachmentDeleteButton(id, attachment.getString("attachmentName"))); return row;/* w w w . j ava 2 s . co m*/ }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Draw line/*from w w w .j av a 2s. 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); } }