List of usage examples for android.widget FrameLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:android.support.v17.leanback.app.SearchSupportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.lb_search_fragment, container, false); FrameLayout searchFrame = (FrameLayout) root.findViewById(R.id.lb_search_frame); mSearchBar = (SearchBar) searchFrame.findViewById(R.id.lb_search_bar); mSearchBar.setSearchBarListener(new SearchBar.SearchBarListener() { @Override// w ww.j a v a 2 s .c o m public void onSearchQueryChange(String query) { if (DEBUG) Log.v(TAG, String.format("onSearchQueryChange %s %s", query, null == mProvider ? "(null)" : mProvider)); if (null != mProvider) { retrieveResults(query); } else { mPendingQuery = query; } } @Override public void onSearchQuerySubmit(String query) { if (DEBUG) Log.v(TAG, String.format("onSearchQuerySubmit %s", query)); submitQuery(query); } @Override public void onKeyboardDismiss(String query) { if (DEBUG) Log.v(TAG, String.format("onKeyboardDismiss %s", query)); queryComplete(); } }); mSearchBar.setSpeechRecognitionCallback(mSpeechRecognitionCallback); mSearchBar.setPermissionListener(mPermissionListener); applyExternalQuery(); readArguments(getArguments()); if (null != mBadgeDrawable) { setBadgeDrawable(mBadgeDrawable); } if (null != mTitle) { setTitle(mTitle); } // Inject the RowsSupportFragment in the results container if (getChildFragmentManager().findFragmentById(R.id.lb_results_frame) == null) { mRowsSupportFragment = new RowsSupportFragment(); getChildFragmentManager().beginTransaction().replace(R.id.lb_results_frame, mRowsSupportFragment) .commit(); } else { mRowsSupportFragment = (RowsSupportFragment) getChildFragmentManager() .findFragmentById(R.id.lb_results_frame); } mRowsSupportFragment.setOnItemViewSelectedListener(new OnItemViewSelectedListener() { @Override public void onItemSelected(ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (DEBUG) { int position = mRowsSupportFragment.getSelectedPosition(); Log.v(TAG, String.format("onItemSelected %d", position)); } updateSearchBarVisiblity(); if (null != mOnItemViewSelectedListener) { mOnItemViewSelectedListener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } } }); mRowsSupportFragment.setOnItemViewClickedListener(mOnItemViewClickedListener); mRowsSupportFragment.setExpand(true); if (null != mProvider) { onSetSearchResultProvider(); } return root; }
From source file:com.rbware.github.androidcouchpotato.app.SearchSupportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.lb_search_fragment, container, false); FrameLayout searchFrame = (FrameLayout) root.findViewById(R.id.lb_search_frame); mSearchBar = (SearchBar) searchFrame.findViewById(R.id.lb_search_bar); mSearchBar.setSearchBarListener(new SearchBar.SearchBarListener() { @Override/*w ww .j a v a2 s .c om*/ public void onSearchQueryChange(String query) { if (DEBUG) Log.v(TAG, String.format("onSearchQueryChange %s %s", query, null == mProvider ? "(null)" : mProvider)); if (null != mProvider) { retrieveResults(query); } else { mPendingQuery = query; } } @Override public void onSearchQuerySubmit(String query) { if (DEBUG) Log.v(TAG, String.format("onSearchQuerySubmit %s", query)); submitQuery(query); } @Override public void onKeyboardDismiss(String query) { if (DEBUG) Log.v(TAG, String.format("onKeyboardDismiss %s", query)); queryComplete(); } }); mSearchBar.setSpeechRecognitionCallback(mSpeechRecognitionCallback); mSearchBar.setPermissionListener(mPermissionListener); applyExternalQuery(); readArguments(getArguments()); if (null != mBadgeDrawable) { setBadgeDrawable(mBadgeDrawable); } if (null != mTitle) { setTitle(mTitle); } // Inject the RowsSupportFragment in the results container if (getChildFragmentManager().findFragmentById(R.id.lb_results_frame) == null) { mRowsSupportFragment = new RowsSupportFragment(); getChildFragmentManager().beginTransaction().replace(R.id.lb_results_frame, mRowsSupportFragment) .commit(); } else { mRowsSupportFragment = (RowsSupportFragment) getChildFragmentManager() .findFragmentById(R.id.lb_results_frame); } mRowsSupportFragment.setOnItemViewSelectedListener(new OnItemViewSelectedListener() { @Override public void onItemSelected(ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (DEBUG) { int position = mRowsSupportFragment.getSelectedPosition(); Log.v(TAG, String.format("onItemSelected %d", position)); } updateSearchBarVisibility(); if (null != mOnItemViewSelectedListener) { mOnItemViewSelectedListener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } } }); mRowsSupportFragment.setOnItemViewClickedListener(mOnItemViewClickedListener); mRowsSupportFragment.setExpand(true); if (null != mProvider) { onSetSearchResultProvider(); } return root; }
From source file:com.mobicage.rogerthat.AbstractHomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { T.UI();//w ww .j ava 2 s .c o m super.onCreate(savedInstanceState); LayoutInflater inflater = getLayoutInflater(); if (CloudConstants.isCityApp()) { setContentView(R.layout.homescreen_3x3_with_qr_code); mPager = (VerticalViewPager) findViewById(R.id.view_pager); mPager.setAdapter(new HomeActivityPagerAdapter()); FrameLayout mainLayer = (FrameLayout) findViewById(R.id.master); inflater.inflate(R.layout.homescreen_3x3_watermark, mainLayer, true); inflater.inflate(R.layout.homescreen_3x3_holder, mainLayer, true); if (AppConstants.SHOW_HOMESCREEN_FOOTER) { // footer is already included in 3x3_with_qr_code mainLayer.findViewById(R.id.homescreen_footer).setVisibility(View.INVISIBLE); } else { for (int id : new int[] { R.id.homescreen_footer, R.id.homescreen_footer_layer, R.id.invisible_homescreen_footer }) { findViewById(id).setVisibility(View.GONE); } } findViewById(R.id.back_btn).setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { mPager.setCurrentItem(0, true); } }); } else { setContentView(AppConstants.HOME_ACTIVITY_LAYOUT); } if (AppConstants.FULL_WIDTH_HEADERS) { findViewById(R.id.homescreen_header_container).setVisibility(View.GONE); findViewById(R.id.homescreen_header_spacer_view).setVisibility(View.GONE); findViewById(R.id.full_width_homescreen_header).setVisibility(View.VISIBLE); } if (!AppConstants.SHOW_HOMESCREEN_FOOTER) { findViewById(R.id.homescreen_footer).setVisibility(View.GONE); final View secondSpacerView = findViewById(R.id.second_spacerview); if (secondSpacerView != null) { secondSpacerView.setVisibility(View.VISIBLE); } } }
From source file:android.support.v7.view.menu.CascadingMenuPopup.java
/** * Prepares and shows the specified menu immediately. * * @param menu the menu to show/*from w w w .ja v a2 s . c om*/ */ private void showMenu(@NonNull MenuBuilder menu) { final LayoutInflater inflater = LayoutInflater.from(mContext); final MenuAdapter adapter = new MenuAdapter(menu, inflater, mOverflowOnly); // Apply "force show icon" setting. There are 3 cases: // (1) This is the top level menu and icon spacing is forced. Add spacing. // (2) This is a submenu. Add spacing if any of the visible menu items has an icon. // (3) This is the top level menu and icon spacing isn't forced. Do not add spacing. if (!isShowing() && mForceShowIcon) { // Case 1 adapter.setForceShowIcon(true); } else if (isShowing()) { // Case 2 adapter.setForceShowIcon(MenuPopup.shouldPreserveIconSpacing(menu)); } // Case 3: Else, don't allow spacing for icons (default behavior; do nothing). final int menuWidth = measureIndividualMenuWidth(adapter, null, mContext, mMenuMaxWidth); final MenuPopupWindow popupWindow = createPopupWindow(); popupWindow.setAdapter(adapter); popupWindow.setWidth(menuWidth); popupWindow.setDropDownGravity(mDropDownGravity); final CascadingMenuInfo parentInfo; final View parentView; if (mShowingMenus.size() > 0) { parentInfo = mShowingMenus.get(mShowingMenus.size() - 1); parentView = findParentViewForSubmenu(parentInfo, menu); } else { parentInfo = null; parentView = null; } if (parentView != null) { // This menu is a cascading submenu anchored to a parent view. popupWindow.setTouchModal(false); popupWindow.setEnterTransition(null); final @HorizPosition int nextMenuPosition = getNextMenuPosition(menuWidth); final boolean showOnRight = nextMenuPosition == HORIZ_POSITION_RIGHT; mLastPosition = nextMenuPosition; final int[] tempLocation = new int[2]; // This popup menu will be positioned relative to the top-left edge // of the view representing its parent menu. parentView.getLocationInWindow(tempLocation); final int parentOffsetLeft = parentInfo.window.getHorizontalOffset() + tempLocation[0]; final int parentOffsetTop = parentInfo.window.getVerticalOffset() + tempLocation[1]; // By now, mDropDownGravity is the resolved absolute gravity, so // this should work in both LTR and RTL. final int x; if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) { if (showOnRight) { x = parentOffsetLeft + menuWidth; } else { x = parentOffsetLeft - parentView.getWidth(); } } else { if (showOnRight) { x = parentOffsetLeft + parentView.getWidth(); } else { x = parentOffsetLeft - menuWidth; } } popupWindow.setHorizontalOffset(x); final int y = parentOffsetTop; popupWindow.setVerticalOffset(y); } else { if (mHasXOffset) { popupWindow.setHorizontalOffset(mXOffset); } if (mHasYOffset) { popupWindow.setVerticalOffset(mYOffset); } final Rect epicenterBounds = getEpicenterBounds(); popupWindow.setEpicenterBounds(epicenterBounds); } final CascadingMenuInfo menuInfo = new CascadingMenuInfo(popupWindow, menu, mLastPosition); mShowingMenus.add(menuInfo); popupWindow.show(); // If this is the root menu, show the title if requested. if (parentInfo == null && mShowTitle && menu.getHeaderTitle() != null) { final ListView listView = popupWindow.getListView(); final FrameLayout titleItemView = (FrameLayout) inflater .inflate(R.layout.abc_popup_menu_header_item_layout, listView, false); final TextView titleView = (TextView) titleItemView.findViewById(android.R.id.title); titleItemView.setEnabled(false); titleView.setText(menu.getHeaderTitle()); listView.addHeaderView(titleItemView, null, false); // Show again to update the title. popupWindow.show(); } }
From source file:com.farmerbb.taskbar.service.DashboardService.java
private void addPlaceholder(int cellId) { FrameLayout placeholder = (FrameLayout) cells.get(cellId).findViewById(R.id.placeholder); SharedPreferences pref = U.getSharedPreferences(this); String providerName = pref.getString("dashboard_widget_" + Integer.toString(cellId) + "_provider", "null"); if (!providerName.equals("null")) { ImageView imageView = (ImageView) placeholder.findViewById(R.id.placeholder_image); ComponentName componentName = ComponentName.unflattenFromString(providerName); List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager .getInstalledProvidersForProfile(Process.myUserHandle()); for (AppWidgetProviderInfo info : providerInfoList) { if (info.provider.equals(componentName)) { Drawable drawable = info.loadPreviewImage(this, -1); if (drawable == null) drawable = info.loadIcon(this, -1); ColorMatrix matrix = new ColorMatrix(); matrix.setSaturation(0); imageView.setImageDrawable(drawable); imageView.setColorFilter(new ColorMatrixColorFilter(matrix)); break; }/*from w w w . j a va2 s . c om*/ } } placeholder.setVisibility(View.VISIBLE); }
From source file:org.bitbucket.ntakimura.android.support.fragment.OpenSourceLicenseFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mLogger.entering(getClass().getName(), "onCreateView", new Object[] { inflater, container, savedInstanceState }); FrameLayout lframe = new FrameLayout(getActivity()); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list);//from w w w .ja v a 2 s .c o m lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light)); ArrayAdapter<Parcelable> adapter = new SoftwareArrayAdapter(getActivity(), R.layout.card_item); if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) { adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS)); } ListView listView = (ListView) lframe.findViewById(android.R.id.list); listView.setAdapter(adapter); getDialog().setTitle(R.string.open_source_licenses); mLogger.exiting(getClass().getName(), "onCreateView", lframe); return lframe; }
From source file:com.jrummyapps.android.colorpicker.ColorPickerDialog.java
private void setupTransparency() { int progress = 255 - Color.alpha(color); transparencySeekBar.setMax(255);// ww w . j av a 2 s . co m transparencySeekBar.setProgress(progress); int percentage = (int) ((double) progress * 100 / 255); transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage)); transparencySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int percentage = (int) ((double) progress * 100 / 255); transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage)); int alpha = 255 - progress; // update items in GridView: for (int i = 0; i < adapter.colors.length; i++) { int color = adapter.colors[i]; int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); adapter.colors[i] = Color.argb(alpha, red, green, blue); } adapter.notifyDataSetChanged(); // update shades: for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = layout.findViewById(R.id.cpv_color_image_view); if (layout.getTag() == null) { // save the original border color layout.setTag(cpv.getBorderColor()); } int color = cpv.getColor(); color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); if (alpha <= ALPHA_THRESHOLD) { cpv.setBorderColor(color | 0xFF000000); } else { cpv.setBorderColor((int) layout.getTag()); } if (cpv.getTag() != null && (Boolean) cpv.getTag()) { // The alpha changed on the selected shaded color. Update the checkmark color filter. if (alpha <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { if (ColorUtils.calculateLuminance(color) >= 0.65) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); } } } cpv.setColor(color); } // update color: int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); color = Color.argb(alpha, red, green, blue); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }
From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java
private void setupTransparency() { int progress = 255 - Color.alpha(color); transparencySeekBar.setMax(255);/*from www . jav a2 s .c o m*/ transparencySeekBar.setProgress(progress); int percentage = (int) ((double) progress * 100 / 255); transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage)); transparencySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int percentage = (int) ((double) progress * 100 / 255); transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage)); int alpha = 255 - progress; // update items in GridView: for (int i = 0; i < adapter.colors.length; i++) { int color = adapter.colors[i]; int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); adapter.colors[i] = Color.argb(alpha, red, green, blue); } adapter.notifyDataSetChanged(); // update shades: for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view); if (layout.getTag() == null) { // save the original border color layout.setTag(cpv.getBorderColor()); } int color = cpv.getColor(); color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); if (alpha <= ALPHA_THRESHOLD) { cpv.setBorderColor(color | 0xFF000000); } else { cpv.setBorderColor((int) layout.getTag()); } if (cpv.getTag() != null && (Boolean) cpv.getTag()) { // The alpha changed on the selected shaded color. Update the checkmark color filter. if (alpha <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { if (ColorUtils.calculateLuminance(color) >= 0.65) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); } } } cpv.setColor(color); } // update color: int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); color = Color.argb(alpha, red, green, blue); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }
From source file:com.jrummyapps.android.colorpicker.ColorPickerDialog.java
void createColorShades(@ColorInt final int color) { final int[] colorShades = getColorShades(color); if (shadesLayout.getChildCount() != 0) { for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); final ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = layout.findViewById(R.id.cpv_color_image_view); cpv.setColor(colorShades[i]); cpv.setTag(false);// ww w . j av a 2 s. c o m iv.setImageDrawable(null); } return; } final int horizontalPadding = getResources().getDimensionPixelSize(R.dimen.cpv_item_horizontal_padding); for (final int colorShade : colorShades) { int layoutResId; if (colorShape == ColorShape.SQUARE) { layoutResId = R.layout.cpv_color_item_square; } else { layoutResId = R.layout.cpv_color_item_circle; } final View view = View.inflate(getActivity(), layoutResId, null); final ColorPanelView colorPanelView = view.findViewById(R.id.cpv_color_panel_view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) colorPanelView.getLayoutParams(); params.leftMargin = params.rightMargin = horizontalPadding; colorPanelView.setLayoutParams(params); colorPanelView.setColor(colorShade); shadesLayout.addView(view); colorPanelView.post(new Runnable() { @Override public void run() { // The color is black when rotating the dialog. This is a dirty fix. WTF!? colorPanelView.setColor(colorShade); } }); colorPanelView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v.getTag() instanceof Boolean && (Boolean) v.getTag()) { colorPickerDialogListener.onColorSelected(dialogId, ColorPickerDialog.this.color); dismiss(); return; // already selected } ColorPickerDialog.this.color = colorPanelView.getColor(); adapter.selectNone(); for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = layout.findViewById(R.id.cpv_color_image_view); iv.setImageResource(cpv == v ? R.drawable.cpv_preset_checked : 0); if (cpv == v && ColorUtils.calculateLuminance(cpv.getColor()) >= 0.65 || Color.alpha(cpv.getColor()) <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(null); } cpv.setTag(cpv == v); } } }); colorPanelView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { colorPanelView.showHint(); return true; } }); } }
From source file:org.deviceconnect.android.manager.setting.OpenSourceLicenseFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mLogger.entering(getClass().getName(), "onCreateView", new Object[] { inflater, container, savedInstanceState }); FrameLayout lframe = new FrameLayout(getActivity()); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list);//from w w w. jav a2s. co m lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light)); ArrayAdapter<Parcelable> adapter = new SoftwareArrayAdapter(getActivity(), R.layout.item_open_source_licenses); if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) { adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS)); } ListView listView = (ListView) lframe.findViewById(android.R.id.list); listView.setAdapter(adapter); getDialog().setTitle(R.string.activity_settings_open_source_licenses); mLogger.exiting(getClass().getName(), "onCreateView", lframe); return lframe; }