List of usage examples for android.widget ProgressBar ProgressBar
public ProgressBar(Context context, AttributeSet attrs, int defStyleAttr)
From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);//from w w w .jav a 2s . c om return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewStandardThumbnail = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewStandardThumbnail.setLayoutParams(imageViewParams); imageViewStandardThumbnail.setVisibility(View.INVISIBLE); imageViewStandardThumbnail.setBackgroundResource(R.drawable.border); imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewStandardThumbnail); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); // Center a view in relative layout RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading videos, display videos if they have been saved before. String videosFilePath = ""; if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page); } else { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page); } boolean videosFileExists = FileUtil.fileExist(videosFilePath); if (videosFileExists) { loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler, VideoListFragmentActivity.videoSource, progressBar, playlistID, page); loadPlaylistVideosFromLocalTask.execute(); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1 if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Playlist, playlistID, pageToken, page); } else { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Search, queryTerm, pageToken, page); } loadVideosTask.execute(); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:org.spinsuite.util.SFAAsyncTask.java
/** * Create Progress Bar //from w w w .j av a 2 s . c o m * @author <a href="mailto:carlsaparadam@gmail.com">Carlos Parada</a> 05/03/2014, 23:07:10 * @param p_attrs * @param p_DefStyle * @return void */ public void createProgressBar(AttributeSet p_attrs, int p_DefStyle) { if (m_ProgressBar == null) m_ProgressBar = new ProgressBar(m_ctx, p_attrs, p_DefStyle); }
From source file:com.wms.opensource.shopfast.fragment.ProductsInCollectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);/* w w w .j a v a 2 s. com*/ return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewPreview = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewPreview.setLayoutParams(imageViewParams); imageViewPreview.setVisibility(View.INVISIBLE); imageViewPreview.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(ProductsInCollectionFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewPreview); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading products, display products if they have been saved before. String productsFilePath = StorageUtil.getTempDirectoryPath(getActivity()) + "/" + PersistFileNameProvider.getProductsFileName(collectionID, page); boolean productsFileExists = FileUtil.fileExist(productsFilePath); if (productsFileExists) { loadProductsFromLocalTask = new LoadCachedProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadProductsFromLocalTask.execute(collectionID); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkConnection(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { loadShopifyProductsTask = new LoadProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadShopifyProductsTask.execute(collectionID); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:org.mariotaku.twidere.fragment.support.BaseSupportListFragment.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.// w w w.j a v a 2s .c o m * * <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. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(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)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:org.quantumbadger.redreader.fragments.WebViewFragment.java
@SuppressLint("NewApi") @Override// w ww .j a va 2 s . com public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mActivity = (AppCompatActivity) getActivity(); CookieSyncManager.createInstance(mActivity); outer = (FrameLayout) inflater.inflate(R.layout.web_view_fragment, null); final RedditPost src_post = getArguments().getParcelable("post"); final RedditPreparedPost post; if (src_post != null) { final RedditParsedPost parsedPost = new RedditParsedPost(src_post, false); post = new RedditPreparedPost(mActivity, CacheManager.getInstance(mActivity), 0, parsedPost, -1, false, false); } else { post = null; } webView = (WebViewFixed) outer.findViewById(R.id.web_view_fragment_webviewfixed); final FrameLayout loadingViewFrame = (FrameLayout) outer .findViewById(R.id.web_view_fragment_loadingview_frame); /*handle download links show an alert box to load this outside the internal browser*/ webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(final String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { { new AlertDialog.Builder(mActivity).setTitle(R.string.download_link_title) .setMessage(R.string.download_link_message) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); getContext().startActivity(i); mActivity.onBackPressed(); //get back from internal browser } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mActivity.onBackPressed(); //get back from internal browser } }).setIcon(android.R.drawable.ic_dialog_alert).show(); } } }); /*handle download links end*/ progressView = new ProgressBar(mActivity, null, android.R.attr.progressBarStyleHorizontal); loadingViewFrame.addView(progressView); loadingViewFrame.setPadding(General.dpToPixels(mActivity, 10), 0, General.dpToPixels(mActivity, 10), 0); final WebSettings settings = webView.getSettings(); settings.setBuiltInZoomControls(true); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(false); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setDomStorageEnabled(true); if (AndroidApi.isHoneyCombOrLater()) { settings.setDisplayZoomControls(false); } // TODO handle long clicks webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, final int newProgress) { super.onProgressChanged(view, newProgress); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { progressView.setProgress(newProgress); progressView.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); } }); } }); if (mUrl != null) { webView.loadUrl(mUrl); } else { webView.loadDataWithBaseURL("https://reddit.com/", html, "text/html; charset=UTF-8", null, null); } webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { if (url == null) return false; if (url.startsWith("data:")) { // Prevent imgur bug where we're directed to some random data URI return true; } // Go back if loading same page to prevent redirect loops. if (goingBack && currentUrl != null && url.equals(currentUrl)) { General.quickToast(mActivity, String.format(Locale.US, "Handling redirect loop (level %d)", -lastBackDepthAttempt), Toast.LENGTH_SHORT); lastBackDepthAttempt--; if (webView.canGoBackOrForward(lastBackDepthAttempt)) { webView.goBackOrForward(lastBackDepthAttempt); } else { mActivity.finish(); } } else { if (RedditURLParser.parse(Uri.parse(url)) != null) { LinkHandler.onLinkClicked(mActivity, url, false); } else { webView.loadUrl(url); currentUrl = url; } } return true; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (mUrl != null && url != null) { final AppCompatActivity activity = mActivity; if (activity != null) { activity.setTitle(url); } } } @Override public void onPageFinished(final WebView view, final String url) { super.onPageFinished(view, url); new Timer().schedule(new TimerTask() { @Override public void run() { AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { if (currentUrl == null || url == null) return; if (!url.equals(view.getUrl())) return; if (goingBack && url.equals(currentUrl)) { General.quickToast(mActivity, String.format(Locale.US, "Handling redirect loop (level %d)", -lastBackDepthAttempt)); lastBackDepthAttempt--; if (webView.canGoBackOrForward(lastBackDepthAttempt)) { webView.goBackOrForward(lastBackDepthAttempt); } else { mActivity.finish(); } } else { goingBack = false; } } }); } }, 1000); } @Override public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { super.doUpdateVisitedHistory(view, url, isReload); } }); final FrameLayout outerFrame = new FrameLayout(mActivity); outerFrame.addView(outer); if (post != null) { final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(mActivity); final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(mActivity, new BezelSwipeOverlay.BezelSwipeListener() { @Override public boolean onSwipe(@BezelSwipeOverlay.SwipeEdge int edge) { toolbarOverlay.setContents(post.generateToolbar(mActivity, false, toolbarOverlay)); toolbarOverlay.show( edge == BezelSwipeOverlay.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT : SideToolbarOverlay.SideToolbarPosition.RIGHT); return true; } @Override public boolean onTap() { if (toolbarOverlay.isShown()) { toolbarOverlay.hide(); return true; } return false; } }); outerFrame.addView(bezelOverlay); outerFrame.addView(toolbarOverlay); bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; } return outerFrame; }
From source file:de.vanita5.twittnuker.fragment.support.BaseSupportListFragment.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 w w .ja v a2 s . c o m * * <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. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setOnScrollListener(this); 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)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:org.getlantern.firetweet.fragment.support.BaseSupportListFragment.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./* w w w . j a va 2 s . com*/ * <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 ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final ExtendedFrameLayout lframe = new ExtendedFrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); lframe.setTouchInterceptor(mInternalOnTouchListener); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setOnScrollListener(this); 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)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.egoclean.testpregnancy.util.ActivityHelper.java
/** * Adds an action button to the compatibility action bar, using menu information from a * {@link android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state * can be changed to show a loading spinner using * {@link ActivityHelper#setRefreshActionButtonCompatState(boolean)}. *//*from ww w .j a va 2s. c om*/ private View addActionButtonCompatFromMenuItem(final MenuItem item) { final ViewGroup actionBar = getActionBarCompat(); if (actionBar == null) { return null; } // Create the separator ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle); separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT)); // Create the button ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle); actionButton.setId(item.getItemId()); actionButton.setLayoutParams(new ViewGroup.LayoutParams( (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height), ViewGroup.LayoutParams.FILL_PARENT)); actionButton.setImageDrawable(item.getIcon()); actionButton.setScaleType(ImageView.ScaleType.CENTER); actionButton.setContentDescription(item.getTitle()); actionButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); } }); actionBar.addView(separator); actionBar.addView(actionButton); if (item.getItemId() == R.id.menu_refresh) { // Refresh buttons should be stateful, and allow for indeterminate progress indicators, // so add those. int buttonWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height); int buttonWidthDiv3 = buttonWidth / 3; ProgressBar indicator = new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle); LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(buttonWidthDiv3, buttonWidthDiv3); indicatorLayoutParams.setMargins(buttonWidthDiv3, buttonWidthDiv3, buttonWidth - 2 * buttonWidthDiv3, 0); indicator.setLayoutParams(indicatorLayoutParams); indicator.setVisibility(View.GONE); indicator.setId(R.id.menu_refresh_progress); actionBar.addView(indicator); } return actionButton; }
From source file:org.solovyev.android.messenger.BaseListFragment.java
@Nonnull private View createListView() { final Context context = getThemeContext(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout progressContainer = new LinearLayout(context); progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID); progressContainer.setOrientation(VERTICAL); progressContainer.setVisibility(GONE); progressContainer.setGravity(CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); progressContainer.addView(progress, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); root.addView(progressContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout listViewContainer = new FrameLayout(context); listViewContainer.setId(INTERNAL_LIST_CONTAINER_ID); final TextView emptyListCaption = new TextView(context); emptyListCaption.setId(INTERNAL_EMPTY_ID); emptyListCaption.setGravity(CENTER); listViewContainer.addView(emptyListCaption, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); final ListViewAwareOnRefreshListener topRefreshListener = getTopPullRefreshListener(); final ListViewAwareOnRefreshListener bottomRefreshListener = getBottomPullRefreshListener(); final View listView; if (topRefreshListener == null && bottomRefreshListener == null) { pullToRefreshMode = null;/*from www .ja v a 2 s. com*/ listView = createListView(context); } else { listView = createPullToRefreshListView(context, topRefreshListener, bottomRefreshListener); } listViewContainer.addView(listView, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); root.addView(listViewContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT)); return root; }
From source file:com.nadmm.airports.ActivityBase.java
public View createContentView(View view) { FrameLayout root = new FrameLayout(this); int white = ContextCompat.getColor(this, android.R.color.white); root.setBackgroundColor(white);/*from ww w. j ava2s . c om*/ root.setDrawingCacheBackgroundColor(white); root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout pframe = new LinearLayout(this); pframe.setId(R.id.INTERNAL_PROGRESS_CONTAINER_ID); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(this, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); FrameLayout lframe = new FrameLayout(this); lframe.setId(R.id.INTERNAL_FRAGMENT_CONTAINER_ID); lframe.setVisibility(View.GONE); lframe.addView(view, 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)); return root; }