List of usage examples for android.widget RelativeLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
private void addDescriptionText(String text) { LayoutInflater inflater = LayoutInflater.from(getActivity()); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_description_item, null, false);//from w ww . java2 s .c o m ((TextView) layout.findViewById(R.id.riii_textView)).setText(text); mInfoLayout.addView(layout); ((ImageView) layout.findViewById(R.id.ic_action_info)) .setColorFilter(getResources().getColor(R.color.material_gray)); }
From source file:org.ale.openwatch.FeedFragmentActivity.java
@Override public void onResume() { super.onResume(); Log.i(TAG, "onResume"); if (internal_user_id > 0) { RelativeLayout profileDrawerItem = (RelativeLayout) findViewById(R.id.profileRow); if (profileDrawerItem != null) { String userThumbnailUrl = OWUser.objects(getApplicationContext(), OWUser.class) .get(internal_user_id).thumbnail_url.get(); if (userThumbnailUrl != null) { ImageLoader.getInstance().displayImage(userThumbnailUrl, (ImageView) profileDrawerItem.findViewById(R.id.icon)); }/*from w w w . ja v a 2 s.c o m*/ } } }
From source file:at.alladin.rmbt.android.map.RMBTMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.map_google, container, false); registerListeners(view);// w ww .j a v a 2 s . co m final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()); if (errorCode != ConnectionResult.SUCCESS) { final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, getActivity(), 0); errorDialog.show(); getFragmentManager().popBackStack(); return view; } View mapView = super.onCreateView(inflater, container, savedInstanceState); final RelativeLayout mapViewContainer = (RelativeLayout) view.findViewById(R.id.mapViewContainer); mapViewContainer.addView(mapView); ProgressBar progessBar = new ProgressBar(getActivity()); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); progessBar.setLayoutParams(layoutParams); progessBar.setVisibility(View.GONE); view.addView(progessBar); return view; }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * Dynamically creates an edit text/*from w ww . jav a2 s .com*/ * * @param open311Attribute contains the open311 attributes */ private void createEditText(Open311Attribute open311Attribute) { LayoutInflater inflater = LayoutInflater.from(getActivity()); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_text_item, null, false); ImageView icon = ((ImageView) layout.findViewById(R.id.ri_ic_question_answer)); icon.setColorFilter(getResources().getColor(R.color.material_gray)); Spannable desc = new SpannableString(MyTextUtils.toSentenceCase(open311Attribute.getDescription())); EditText editText = ((EditText) layout.findViewById(R.id.riti_editText)); if (open311Attribute.getRequired()) { Spannable req = new SpannableString("(required)"); req.setSpan(new ForegroundColorSpan(Color.RED), 0, req.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); editText.setHint(TextUtils.concat(desc, " ", req)); } else { editText.setHint(desc); } if (Open311DataType.NUMBER.equals(open311Attribute.getDatatype())) { editText.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) { editText.setInputType(InputType.TYPE_CLASS_DATETIME); } // Restore view state from attribute result hash map AttributeValue av = mAttributeValueHashMap.get(open311Attribute.getCode()); if (av != null) { editText.setText(av.getSingleValue()); } // Dynamically fill stop id if this is a transit service // And if this is a bus stop field if (ServiceUtils.isTransitServiceByType(mService.getType()) && ServiceUtils.isStopIdField(open311Attribute.getDescription())) { icon.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ri_flag_triangle)); ObaStop obaStop = getIssueLocationHelper().getObaStop(); if (obaStop != null) { editText.setText(obaStop.getStopCode()); } } mInfoLayout.addView(layout); mDynamicAttributeUIMap.put(open311Attribute.getCode(), editText); }
From source file:org.egov.android.view.activity.CreateComplaintActivity.java
/** * Function used to show the image added to complaint in image view. A close icon is shown at * the top right corner of the image to delete it * // ww w . ja v a 2 s . c om * @param imagePath */ @SuppressLint("InflateParams") private void _addImageView(String imagePath) { final ImageView image_container = (ImageView) findViewById(R.id.image_container); LinearLayout container = (LinearLayout) findViewById(R.id.container); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.add_photo, null); RelativeLayout inner_container = (RelativeLayout) view.findViewById(R.id.inner_container); LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(100), _dpToPix(100)); inner_container.setLayoutParams(inner_container_params); ImageView image = (ImageView) view.findViewById(R.id.image); image.setImageBitmap(_getBitmapImage(imagePath)); image.setTag(imagePath); container.addView(inner_container); imageUrl.add(imagePath); image_container.setImageBitmap(_getBitmapImage(imagePath)); ImageView delete_icon = (ImageView) view.findViewById(R.id.delete_photo); delete_icon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { file_upload_limit--; RelativeLayout deleteView = (RelativeLayout) v.getParent(); ((LinearLayout) findViewById(R.id.container)).removeView(deleteView); ImageView image = (ImageView) deleteView.findViewById(R.id.image); _deleteFile(image.getTag().toString()); _reorderFiles(); } }); inner_container.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ImageView image = (ImageView) v.findViewById(R.id.image); ((ImageView) findViewById(R.id.image_container)) .setImageBitmap(_getBitmapImage(image.getTag().toString())); } }); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.hr_scroll); hsv.scrollTo(hsv.getWidth() + 600, 0); } }, 500); }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * Dynamically creates checkboxes/*from www .j ava 2 s . c o m*/ * * @param open311Attribute contains the open311 attributes */ private void createMultiValueList(Open311Attribute open311Attribute) { ArrayList<Object> values = (ArrayList<Object>) open311Attribute.getValues(); if (values != null && values.size() > 0) { LayoutInflater inflater = LayoutInflater.from(getActivity()); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_multi_value_list_item, null, false); ((ImageView) layout.findViewById(R.id.ri_ic_checkbox)) .setColorFilter(getResources().getColor(R.color.material_gray)); Spannable word = new SpannableString(open311Attribute.getDescription()); ((TextView) layout.findViewById(R.id.rimvli_textView)).setText(word); if (open311Attribute.getRequired()) { Spannable wordTwo = new SpannableString(" *Required"); wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ((TextView) layout.findViewById(R.id.rimvli_textView)).append(wordTwo); } // Restore view state from attribute result hash map AttributeValue av = mAttributeValueHashMap.get(open311Attribute.getCode()); LinearLayout cg = (LinearLayout) layout.findViewById(R.id.rimvli_checkBoxGroup); for (int i = 0; i < values.size(); i++) { LinkedHashMap<String, String> value = (LinkedHashMap<String, String>) values.get(i); CheckBox cb = new CheckBox(getActivity()); cg.addView(cb); String attributeKey = ""; String attributeValue = ""; for (LinkedHashMap.Entry<String, String> entry : value.entrySet()) { if (Open311Attribute.NAME.equals(entry.getKey())) { cb.setText(entry.getValue()); if (av != null && av.getValues().contains(entry.getValue())) { cb.setChecked(true); } attributeKey = open311Attribute.getCode() + entry.getValue(); } else if (Open311Attribute.KEY.equals(entry.getKey())) { attributeValue = entry.getValue(); } } mOpen311AttributeKeyNameMap.put(attributeKey, attributeValue); } mInfoLayout.addView(layout); mDynamicAttributeUIMap.put(open311Attribute.getCode(), cg); } }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
/** * Dynamically creates radio buttons// w w w .j a v a 2s.c o m * * @param open311Attribute contains the open311 attributes */ private void createSingleValueList(Open311Attribute open311Attribute) { ArrayList<Object> values = (ArrayList<Object>) open311Attribute.getValues(); if (values != null && values.size() > 0) { LayoutInflater inflater = LayoutInflater.from(getActivity()); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_single_value_list_item, null, false); layout.setSaveEnabled(true); ((ImageView) layout.findViewById(R.id.ri_ic_radio)) .setColorFilter(getResources().getColor(R.color.material_gray)); Spannable word = new SpannableString(open311Attribute.getDescription()); ((TextView) layout.findViewById(R.id.risvli_textView)).setText(word); if (open311Attribute.getRequired()) { Spannable wordTwo = new SpannableString(" *Required"); wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ((TextView) layout.findViewById(R.id.risvli_textView)).append(wordTwo); } RadioGroup rg = (RadioGroup) layout.findViewById(R.id.risvli_radioGroup); rg.setOrientation(RadioGroup.VERTICAL); // Restore view state from attribute result hash map AttributeValue av = mAttributeValueHashMap.get(open311Attribute.getCode()); String entryValue = null; if (av != null) { entryValue = av.getSingleValue(); } for (int i = 0; i < values.size(); i++) { LinkedHashMap<String, String> value = (LinkedHashMap<String, String>) values.get(i); RadioButton rb = new RadioButton(getActivity()); rg.addView(rb); //the RadioButtons are added to the radioGroup instead of the layout String attributeKey = ""; String attributeValue = ""; for (LinkedHashMap.Entry<String, String> entry : value.entrySet()) { if (Open311Attribute.NAME.equals(entry.getKey())) { rb.setText(entry.getValue()); if (entryValue != null && entryValue.equalsIgnoreCase(entry.getValue())) { rb.setChecked(true); } attributeKey = open311Attribute.getCode() + entry.getValue(); } else if (Open311Attribute.KEY.equals(entry.getKey())) { attributeValue = entry.getValue(); } } mOpen311AttributeKeyNameMap.put(attributeKey, attributeValue); } mInfoLayout.addView(layout); mDynamicAttributeUIMap.put(open311Attribute.getCode(), rg); } }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
/** * Adds a new TerminalBridge to the current set of views in our ViewFlipper. * * @param bridge/* w w w. j av a 2 s . c o m*/ * TerminalBridge to add to our ViewFlipper * @return the child index of the new view in the ViewFlipper */ private int addNewTerminalView(TerminalBridge bridge) { // let them know about our prompt handler services bridge.promptHelper.setHandler(promptHandler); // inflate each terminal view RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.item_terminal, flip, false); // set the terminal overlay text TextView overlay = (TextView) view.findViewById(R.id.terminal_overlay); overlay.setText(bridge.host.getNickname()); // and add our terminal view control, using index to place behind // overlay TerminalView terminal = new TerminalView(ConsoleActivity.this, bridge); terminal.setId(R.id.console_flip); view.addView(terminal, 0); synchronized (flip) { // finally attach to the flipper flip.addView(view); return flip.getChildCount() - 1; } }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
private void createTripHeadsign(String text) { LayoutInflater inflater = LayoutInflater.from(getActivity()); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_description_item, null, false);/*from w ww . j av a2s .co m*/ LinearLayout linear = (LinearLayout) findViewById(R.id.ri_report_stop_problem); TextView tv = ((TextView) layout.findViewById(R.id.riii_textView)); tv.setText(UIUtils.formatDisplayText(text)); tv.setTypeface(null, Typeface.NORMAL); linear.addView(layout, 0); ImageView imageView = (ImageView) layout.findViewById(R.id.ic_action_info); imageView.setImageResource(R.drawable.ic_trip_details); imageView.setColorFilter(getResources().getColor(R.color.material_gray)); }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert/*from w w w.j a v a2 s . c o m*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }