List of usage examples for android.widget FrameLayout addView
public void addView(View child, int index)
From source file:com.mongolduu.android.ng.GDFragmentActivity.java
/** * <p>//from w w w . ja v a 2 s. co m * Set the activity content to an explicit view. This view is placed * directly into the activity's view hierarchy. It can itself be a complex * view hierarchy. * </p> * <p> * This method is an equivalent to setContentView(View, LayoutParams) that * automatically wraps the given layout in an {@link ActionBarHost} if * needed. * </p> * * @param view The desired content to display. * @param params Layout parameters for the view. * @see #setActionBarContentView(View) * @see #setActionBarContentView(int) */ public void setActionBarContentView(View view, LayoutParams params) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); contentView.addView(view, params); }
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. j av 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: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 ww . jav a2 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.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; }
From source file:com.facebook.notifications.internal.activity.CardActivity.java
private void beginLoadingContent() { if (assetManager == null || contentManager == null) { Log.e(LOG_TAG, "Asset & content manager should be available!"); return;/*ww w. j a va 2 s . c o m*/ } if (configurationPayload == null) { Log.e(LOG_TAG, "No card payload is available!"); return; } ProgressBar loadingView = new ProgressBar(this); loadingView.setIndeterminate(true); int backgroundColor = ColorAssetHandler.fromRGBAHex(configurationPayload.optString("backdropColor")); FrameLayout loadingViewFrame = new FrameLayout(this); loadingViewFrame.setBackgroundColor(backgroundColor); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; loadingViewFrame.addView(loadingView, layoutParams); setContentView(loadingViewFrame); final Handler handler = new Handler(); if (configurationPayload == null) { return; } assetManager.cachePayload(configurationPayload, new AssetManager.CacheCompletionCallback() { @Override public void onCacheCompleted(@NonNull JSONObject payload) { final CardConfiguration configuration; try { configuration = new CardConfiguration(configurationPayload, assetManager, contentManager); } catch (JSONException ex) { Log.e(LOG_TAG, "Error while parsing JSON", ex); return; } handler.post(new Runnable() { @Override public void run() { displayConfiguration(configuration); } }); } }); }
From source file:com.todoroo.astrid.activity.ExpandableListFragment.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. * * <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. *///from w w w . j a va2 s. c o m @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout root = new FrameLayout(getActivity()); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); root.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); root.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); root.setLayoutParams(lp); return root; }
From source file:de.vanita5.twittnuker.fragment.support.SetUserNicknameDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final String nick = args.getString(EXTRA_NAME); final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); builder.setTitle(R.string.set_nickname); builder.setPositiveButton(android.R.string.ok, this); if (!TextUtils.isEmpty(nick)) { builder.setNeutralButton(R.string.clear, this); }/*from w ww . j a v a 2 s .c o m*/ builder.setNegativeButton(android.R.string.cancel, null); final FrameLayout view = new FrameLayout(wrapped); mEditText = new EditText(wrapped); final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources() .getDimensionPixelSize(R.dimen.element_spacing_normal); view.addView(mEditText, lp); builder.setView(view); mEditText.setText(nick); return builder.create(); }
From source file:org.mariotaku.twidere.fragment.SetUserNicknameDialogFragment.java
@NonNull @Override/*from ww w. ja v a2 s. co m*/ public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final String nick = args.getString(EXTRA_NAME); final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.set_nickname); builder.setPositiveButton(android.R.string.ok, this); if (!TextUtils.isEmpty(nick)) { builder.setNeutralButton(R.string.clear, this); } builder.setNegativeButton(android.R.string.cancel, null); final FrameLayout view = new FrameLayout(context); mEditText = new AppCompatEditText(context); final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources() .getDimensionPixelSize(R.dimen.element_spacing_normal); view.addView(mEditText, lp); builder.setView(view); mEditText.setText(nick); return builder.create(); }
From source file:org.mariotaku.twidere.fragment.support.SetUserNicknameDialogFragment.java
@NonNull @Override//from w w w. jav a 2 s . co m public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final String nick = args.getString(EXTRA_NAME); final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); builder.setTitle(R.string.set_nickname); builder.setPositiveButton(android.R.string.ok, this); if (!TextUtils.isEmpty(nick)) { builder.setNeutralButton(R.string.clear, this); } builder.setNegativeButton(android.R.string.cancel, null); final FrameLayout view = new FrameLayout(wrapped); mEditText = new AppCompatEditText(wrapped); final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources() .getDimensionPixelSize(R.dimen.element_spacing_normal); view.addView(mEditText, lp); builder.setView(view); mEditText.setText(nick); return builder.create(); }
From source file:com.aboveware.abovegame.expandable.ExpandableListFragment.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 ww w . j a v a2s . c om*/ * <p/> * <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 * AbsListFragment. In particular, this is currently the only way to have the * built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout root = new FrameLayout(getActivity()); FrameLayout lframe = new FrameLayout(getActivity()); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); root.setLayoutParams(lp); return root; }
From source file:com.handmark.pulltorefresh.library.PullToRefreshListView.java
@Override protected void handleStyledAttributes(TypedArray a) { super.handleStyledAttributes(a); mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true); if (mListViewExtrasEnabled) { final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL); // Create Loading Views ready for use later FrameLayout frame = new FrameLayout(getContext()); mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a); mHeaderLoadingView.setVisibility(View.GONE); frame.addView(mHeaderLoadingView, lp); mRefreshableView.addHeaderView(frame, null, false); mLvFooterLoadingFrame = new FrameLayout(getContext()); mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a); mFooterLoadingView.setVisibility(View.GONE); mLvFooterLoadingFrame.addView(mFooterLoadingView, lp); /**/*from w w w .j a v a2 s . c o m*/ * If the value for Scrolling While Refreshing hasn't been * explicitly set via XML, enable Scrolling While Refreshing. */ if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) { setScrollingWhileRefreshingEnabled(true); } } }