List of usage examples for android.widget ScrollView addView
@Override public void addView(View child)
From source file:ch.fixme.status.Main.java
private void populateDataHs() { try {/*w ww.jav a 2 s . c o m*/ HashMap<String, Object> data = new ParseGeneric(mResultHs).getData(); // Initialize views LayoutInflater inflater = getLayoutInflater(); LinearLayout vg = (LinearLayout) inflater.inflate(R.layout.base, null); ScrollView scroll = (ScrollView) findViewById(R.id.scroll); scroll.removeAllViews(); scroll.addView(vg); // Mandatory fields ((TextView) findViewById(R.id.space_name)).setText((String) data.get(ParseGeneric.API_NAME)); ((TextView) findViewById(R.id.space_url)).setText((String) data.get(ParseGeneric.API_URL)); getImageTask = new GetImage(R.id.space_image); getImageTask.execute((String) data.get(ParseGeneric.API_LOGO)); // Status text String status_txt = ""; if ((Boolean) data.get(ParseGeneric.API_STATUS)) { status_txt = OPEN; ((TextView) findViewById(R.id.status_txt)) .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_online, 0, 0, 0); } else { status_txt = CLOSED; ((TextView) findViewById(R.id.status_txt)) .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_busy, 0, 0, 0); } if (data.containsKey(ParseGeneric.API_STATUS_TXT)) { status_txt += ": " + (String) data.get(ParseGeneric.API_STATUS_TXT); } ((TextView) findViewById(R.id.status_txt)).setText(status_txt); // Status last change if (data.containsKey(ParseGeneric.API_LASTCHANGE)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setAutoLinkMask(0); tv.setText( getString(R.string.api_lastchange) + " " + (String) data.get(ParseGeneric.API_LASTCHANGE)); vg.addView(tv); } // Status duration if (data.containsKey(ParseGeneric.API_EXT_DURATION) && (Boolean) data.get(ParseGeneric.API_STATUS)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText(getString(R.string.api_duration) + " " + (String) data.get(ParseGeneric.API_EXT_DURATION) + getString(R.string.api_duration_hours)); vg.addView(tv); } // Location Pattern ptn = Pattern.compile("^.*$", Pattern.DOTALL); if (data.containsKey(ParseGeneric.API_ADDRESS) || data.containsKey(ParseGeneric.API_LON)) { TextView title = (TextView) inflater.inflate(R.layout.title, null); title.setText(getString(R.string.api_location)); vg.addView(title); inflater.inflate(R.layout.separator, vg); // Address if (data.containsKey(ParseGeneric.API_ADDRESS)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setAutoLinkMask(0); tv.setText((String) data.get(ParseGeneric.API_ADDRESS)); Linkify.addLinks(tv, ptn, MAP_SEARCH); vg.addView(tv); } // Lon/Lat if (data.containsKey(ParseGeneric.API_LON) && data.containsKey(ParseGeneric.API_LAT)) { String addr = (data.containsKey(ParseGeneric.API_ADDRESS)) ? (String) data.get(ParseGeneric.API_ADDRESS) : getString(R.string.empty); TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setAutoLinkMask(0); tv.setText((String) data.get(ParseGeneric.API_LON) + ", " + (String) data.get(ParseGeneric.API_LAT)); Linkify.addLinks(tv, ptn, String.format(MAP_COORD, (String) data.get(ParseGeneric.API_LAT), (String) data.get(ParseGeneric.API_LON), addr)); vg.addView(tv); } } // Contact if (data.containsKey(ParseGeneric.API_PHONE) || data.containsKey(ParseGeneric.API_TWITTER) || data.containsKey(ParseGeneric.API_IRC) || data.containsKey(ParseGeneric.API_EMAIL) || data.containsKey(ParseGeneric.API_ML)) { TextView title = (TextView) inflater.inflate(R.layout.title, null); title.setText(R.string.api_contact); vg.addView(title); inflater.inflate(R.layout.separator, vg); // Phone if (data.containsKey(ParseGeneric.API_PHONE)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_PHONE)); vg.addView(tv); } // SIP if (data.containsKey(ParseGeneric.API_SIP)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_SIP)); vg.addView(tv); } // Twitter if (data.containsKey(ParseGeneric.API_TWITTER)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText(TWITTER + (String) data.get(ParseGeneric.API_TWITTER)); vg.addView(tv); } // Identica if (data.containsKey(ParseGeneric.API_IDENTICA)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_IDENTICA)); vg.addView(tv); } // Foursquare if (data.containsKey(ParseGeneric.API_FOURSQUARE)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText(FOURSQUARE + (String) data.get(ParseGeneric.API_FOURSQUARE)); vg.addView(tv); } // IRC if (data.containsKey(ParseGeneric.API_IRC)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setAutoLinkMask(0); tv.setText((String) data.get(ParseGeneric.API_IRC)); vg.addView(tv); } // Email if (data.containsKey(ParseGeneric.API_EMAIL)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_EMAIL)); vg.addView(tv); } // Jabber if (data.containsKey(ParseGeneric.API_JABBER)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_JABBER)); vg.addView(tv); } // Mailing-List if (data.containsKey(ParseGeneric.API_ML)) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText((String) data.get(ParseGeneric.API_ML)); vg.addView(tv); } } // Sensors if (data.containsKey(ParseGeneric.API_SENSORS)) { // Title TextView title = (TextView) inflater.inflate(R.layout.title, null); title.setText(getString(R.string.api_sensors)); vg.addView(title); inflater.inflate(R.layout.separator, vg); HashMap<String, ArrayList<HashMap<String, String>>> sensors = (HashMap<String, ArrayList<HashMap<String, String>>>) data .get(ParseGeneric.API_SENSORS); Set<String> names = sensors.keySet(); Iterator<String> it = names.iterator(); while (it.hasNext()) { String name = it.next(); // Subtitle String name_title = name.toLowerCase().replace("_", " "); name_title = name_title.substring(0, 1).toUpperCase() + name_title.substring(1, name_title.length()); TextView subtitle = (TextView) inflater.inflate(R.layout.subtitle, null); subtitle.setText(name_title); vg.addView(subtitle); // Sensors data ArrayList<HashMap<String, String>> sensorsData = sensors.get(name); for (HashMap<String, String> elem : sensorsData) { RelativeLayout rl = (RelativeLayout) inflater.inflate(R.layout.entry_sensor, null); if (elem.containsKey(ParseGeneric.API_VALUE)) { ((TextView) rl.findViewById(R.id.entry_value)) .setText(elem.get(ParseGeneric.API_VALUE)); } else { rl.findViewById(R.id.entry_value).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_UNIT)) { ((TextView) rl.findViewById(R.id.entry_unit)).setText(elem.get(ParseGeneric.API_UNIT)); } else { rl.findViewById(R.id.entry_unit).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_NAME2)) { ((TextView) rl.findViewById(R.id.entry_name)).setText(elem.get(ParseGeneric.API_NAME2)); } else { rl.findViewById(R.id.entry_name).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_LOCATION2)) { ((TextView) rl.findViewById(R.id.entry_location)) .setText(elem.get(ParseGeneric.API_LOCATION2)); } else { rl.findViewById(R.id.entry_location).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_DESCRIPTION)) { ((TextView) rl.findViewById(R.id.entry_description)) .setText(elem.get(ParseGeneric.API_DESCRIPTION)); } else { rl.findViewById(R.id.entry_description).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_PROPERTIES)) { ((TextView) rl.findViewById(R.id.entry_properties)) .setText(elem.get(ParseGeneric.API_PROPERTIES)); } else { rl.findViewById(R.id.entry_properties).setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_MACHINES)) { ((TextView) rl.findViewById(R.id.entry_other)) .setText(elem.get(ParseGeneric.API_MACHINES)); } else if (elem.containsKey(ParseGeneric.API_NAMES)) { ((TextView) rl.findViewById(R.id.entry_other)) .setText(elem.get(ParseGeneric.API_NAMES)); } else { rl.findViewById(R.id.entry_other).setVisibility(View.GONE); } vg.addView(rl); } } } // Stream and cam if (data.containsKey(ParseGeneric.API_STREAM) || data.containsKey(ParseGeneric.API_CAM)) { TextView title = (TextView) inflater.inflate(R.layout.title, null); title.setText(getString(R.string.api_stream)); vg.addView(title); inflater.inflate(R.layout.separator, vg); // Stream if (data.containsKey(ParseGeneric.API_STREAM)) { HashMap<String, String> stream = (HashMap<String, String>) data.get(ParseGeneric.API_STREAM); for (Entry<String, String> entry : stream.entrySet()) { final String type = entry.getKey(); final String url = entry.getValue(); TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText(url); tv.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse(url), type); startActivity(i); } }); vg.addView(tv); } } // Cam if (data.containsKey(ParseGeneric.API_CAM)) { HashMap<String, String> cam = (HashMap<String, String>) data.get(ParseGeneric.API_CAM); for (String value : cam.values()) { TextView tv = (TextView) inflater.inflate(R.layout.entry, null); tv.setText(value); vg.addView(tv); } } } } catch (Exception e) { e.printStackTrace(); showError(e.getClass().getCanonicalName(), e.getLocalizedMessage() + getString(R.string.error_generic)); } }
From source file:org.adblockplus.android.AdvancedPreferences.java
@Override protected Dialog onCreateDialog(final int id) { Dialog dialog = null;/*from w w w .j av a 2 s . c om*/ switch (id) { case CONFIGURATION_DIALOG: final List<String> items = new ArrayList<String>(); items.add(AdblockPlus.getDeviceName()); items.add(String.format("API: %d Build: %d", Build.VERSION.SDK_INT, AdblockPlus.getApplication().getBuildNumber())); final ProxyService proxyService = this.serviceBinder.get(); if (proxyService != null) { items.add(String.format("Local port: %d", proxyService.port)); if (proxyService.isIptables()) { items.add("Running in root mode"); items.add("iptables output:"); final List<String> output = IptablesProxyConfigurator .getIptablesOutput(getApplicationContext()); if (output != null) { for (final String line : output) { if (StringUtils.isNotEmpty(line)) items.add(line); } } } if (proxyService.isNativeProxyAutoConfigured()) { items.add("Has native proxy auto configured"); } if (ProxyService.GLOBAL_PROXY_USER_CONFIGURABLE) { final ProxyProperties pp = ProxyProperties.fromContext(getApplicationContext()); if (pp != null) { items.add("System settings:"); items.add(String.format("Host: [%s] Port: [%d] Excl: [%s]", pp.getHost(), pp.getPort(), pp.getExclusionList())); } } items.add("Proxy settings:"); items.add(String.format("Host: [%s] Port: [%s] Excl: [%s]", proxyService.proxy.props.getProperty("adblock.proxyHost"), proxyService.proxy.props.getProperty("adblock.proxyPort"), proxyService.proxy.props.getProperty("adblock.proxyExcl"))); if (proxyService.proxy.props.getProperty("adblock.auth") != null) items.add("Auth: yes"); } else { items.add("Service not running"); } final ScrollView scrollPane = new ScrollView(this); final TextView messageText = new TextView(this); messageText.setPadding(12, 6, 12, 6); messageText.setText(TextUtils.join("\n", items)); messageText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); final TextView showTextParam = (TextView) v; manager.setText(showTextParam.getText()); Toast.makeText(v.getContext(), R.string.msg_clipboard, Toast.LENGTH_SHORT).show(); } }); scrollPane.addView(messageText); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(scrollPane).setTitle(R.string.configuration_name) .setIcon(android.R.drawable.ic_dialog_info).setCancelable(false) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); dialog = builder.create(); break; } return dialog; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the CPU value for each core. * /*w w w . ja va 2 s . c o m*/ * @return a ScrollView containing a list of BarView. */ private View createCPUListDialog() { ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getCpu_cores(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFBarView barView = createBarView(value); row.addView(barView); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment if (getArguments() != null) { mType = getArguments().getInt("type"); }/*from ww w . ja v a 2s . c o m*/ LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); linearLayout.setLayoutParams(params); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setLayoutParams(params); linearLayout.addView(scrollView); TextView textView = new TextView(getActivity()); textView.setLayoutParams(params); int padding = getResources().getDimensionPixelOffset(R.dimen.padding); textView.setPadding(padding, padding, padding, padding); switch (mType) { case Constants.FRAGMENT_ABOUT: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_about); break; case Constants.FRAGMENT_LICENSE: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_license); break; case Constants.FRAGMENT_POLICY: textView.setGravity(Gravity.START); textView.setText(getContent()); getActivity().setTitle(R.string.settings_policy); break; } setHasOptionsMenu(true); scrollView.addView(textView); return linearLayout; }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public View createLoadingView() { ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("gg_scroll"); sv.setFillViewport(true);/*from w ww. j a v a 2 s . co m*/ LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setGravity(Gravity.CENTER); ProgressBar pb = new ProgressBar(getActivity()); pb.getIndeterminateDrawable().setColorFilter(SIAApp.SIA_APP.school.getAccentColor(), PorterDuff.Mode.SRC_IN); pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); pb.setVisibility(ProgressBar.VISIBLE); l.addView(pb); sv.addView(l); return sv; }
From source file:eu.hydrologis.geopaparazzi.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = context.getResources().getColor(R.color.formbgcolor); int textColor = context.getResources().getColor(R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);/*from ww w . j a v a 2 s .c o m*/ scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); DataType type = DataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final EditText editView = new EditText(context); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setText(value); // editView.setEnabled(!isReadOnly); editView.setFocusable(!isReadOnly); // editView.setTextAppearance(context, android.R.style.TextAppearance_Medium); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } switch (type) { case DOUBLE: case FLOAT: editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; case PHONE: editView.setInputType(InputType.TYPE_CLASS_PHONE); break; case DATE: editView.setInputType(InputType.TYPE_CLASS_DATETIME); break; case INTEGER: editView.setInputType(InputType.TYPE_CLASS_NUMBER); break; default: break; } editView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // ignore } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } public void afterTextChanged(Editable s) { String text = editView.getText().toString(); feature.setAttribute(name, text); } }); linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText("Area: " + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText("Length: " + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }
From source file:eu.geopaparazzi.core.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formbgcolor); int textColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//ww w . j a v a 2 s . c o m scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); EDataType type = EDataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final TextView editView = getEditView(feature, name, type, value); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setFocusable(!isReadOnly); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText(context.getString(eu.geopaparazzi.core.R.string.area_colon) + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText(context.getString(eu.geopaparazzi.core.R.string.length_colon) + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainFare() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();/* w w w. j a va2 s . c om*/ mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now. \nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); } mListFr = new ArrayList<List<String>>(); List<String> list; Element tmp; while (iterator.hasNext()) { tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); mListFr.add(list); } mDetails = new Details(mListFr, TrainEnquiry.FARE, mTrainNumber); } else { mListFr = mDetails.getList(); } mTblLayoutFr = new TableLayout(mActivity); TableRow row; TextView tv1, tv2; mTblLayoutFr.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListFr.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv1.setText(" " + mListFr.get(i).get(0)); tv2.setText(" " + mListFr.get(i).get(1)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTblLayoutFr.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Fare details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutFr); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
/** * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/* w ww .j a va 2 s .c o m*/ * @param label label * @param pictures the value are the ids and binary data of the images. * @param constraintDescription constraints */ public GPictureView(final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String label, Map<String, Map<String, String>> pictures, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); thumbnailWidth = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_width); thumbnailHeight = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_height); mFragmentDetail = fragmentDetail; _pictures = pictures; PICTURE_VIEW_RESULT = requestCode; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setPadding(10, 5, 10, 5); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); String t = label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription; textView.setText(t); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.take_picture); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(activity, CameraActivity.class); cameraIntent.putExtra(FormUtilities.MAIN_APP_WORKING_DIRECTORY, fragmentDetail.getWorkingDirectory()); fragmentDetail.startActivityForResult(cameraIntent, requestCode); } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setHorizontalScrollBarEnabled(true); scrollView.setOverScrollMode(HorizontalScrollView.OVER_SCROLL_ALWAYS); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageLayout.setLayoutParams(imageLayoutParams); imageLayout.setPadding(15, 5, 15, 5); imageLayout.setOrientation(LinearLayout.HORIZONTAL); imageLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); scrollView.addView(imageLayout); updateValueForm(); try { refresh(activity); } catch (Exception e) { //GPLog.error(this, null, e); e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
From source file:terse.a1.TerseActivity.java
void SetContentViewWithHomeButtonAndScroll(View v) { Button btn = new Button(this); btn.setText("[HOME]"); // btn.setTextSize(15); // btn.setHeight(25); // btn.setMaxHeight(25); btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks startTerseActivity("/Top", ""); };//from w w w .j av a 2s.c om }); LinearLayout linear = new LinearLayout(this); linear.setOrientation(LinearLayout.VERTICAL); linear.addView(btn); linear.addView(v); ScrollView scrollv = new ScrollView(this); scrollv.addView(linear); setContentView(scrollv); }