List of usage examples for android.widget ProgressBar ProgressBar
public ProgressBar(Context context, AttributeSet attrs, int defStyleAttr)
From source file:org.sufficientlysecure.keychain.remote.ui.SelectPublicKeyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getContext(); FrameLayout root = new FrameLayout(context); LinearLayout progressContainer = new LinearLayout(context); progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID); progressContainer.setOrientation(LinearLayout.VERTICAL); progressContainer.setGravity(Gravity.CENTER); progressContainer.setVisibility(View.GONE); ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); progressContainer.addView(progressBar, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(progressContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); FrameLayout listContainer = new FrameLayout(context); listContainer.setId(INTERNAL_LIST_CONTAINER_ID); TextView textView = new TextView(context); textView.setId(INTERNAL_EMPTY_VIEW_ID); textView.setGravity(Gravity.CENTER); listContainer.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); LinearLayout innerListContainer = new LinearLayout(context); innerListContainer.setOrientation(LinearLayout.VERTICAL); mSearchView = new EditText(context); mSearchView.setId(android.R.id.input); mSearchView.setHint(R.string.menu_search); mSearchView.setCompoundDrawablesWithIntrinsicBounds( ContextCompat.getDrawable(context, R.drawable.ic_search_grey_24dp), null, null, null); innerListContainer.addView(mSearchView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); RecyclerView listView = new RecyclerView(context); listView.setId(INTERNAL_LIST_VIEW_ID); int padding = FormattingUtils.dpToPx(context, 8); listView.setPadding(padding, 0, padding, 0); listView.setClipToPadding(false);/*from w ww . java 2s . c o m*/ innerListContainer.addView(listView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); listContainer.addView(innerListContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(listContainer, 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.xalops.spotifystreamer.fragments.SearchListFragment.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. *///ww w . ja v a 2s. c o m @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); //QUICK Inflate from XML file //inflater.inflate(R.layout.search_list_detail, root); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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)); // ------------------------------------------------------------------ RelativeLayout rlayout = new RelativeLayout(context); EditText et = new EditText(getActivity()); et.setId(INTERNAL_SEARCH_FIELD_ID); et.setSingleLine(true); et.setInputType(InputType.TYPE_CLASS_TEXT); et.setImeOptions(EditorInfo.IME_ACTION_DONE); RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_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)); 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)); rlayout.addView(et, etRLayoutParams); rlayout.addView(lframe, lframeRLayoutParams); root.addView(rlayout, 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.onebusaway.android.ui.ListFragment.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. */// ww w. j a va2s . c o m @Override @SuppressWarnings("deprecation") public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(R.id.loading); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(R.id.listContainer); TextView tv = new TextView(getActivity()); tv.setId(R.id.internalEmpty); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:org.floens.chan.ui.activity.ImageViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP); super.onCreate(savedInstanceState); if (postAdapterStatic == null || threadManagerStatic == null) { Logger.e(TAG, "postadapter or threadmanager null"); finish();/*w w w.jav a 2 s . c om*/ return; } threadManager = threadManagerStatic; threadManagerStatic = null; postAdapter = postAdapterStatic; postAdapterStatic = null; int selectedId = selectedIdStatic; selectedIdStatic = -1; ThemeHelper.setTheme(this); progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg)); progressBar.setIndeterminate(false); progressBar.setMax(1000000); final FrameLayout decorView = (FrameLayout) getWindow().getDecorView(); decorView.addView(progressBar); progressBar.post(new Runnable() { @Override public void run() { View contentView = decorView.findViewById(android.R.id.content); progressBar.setY(contentView.getY() - progressBar.getHeight() / 2); } }); // Get the posts with images ArrayList<Post> imagePosts = new ArrayList<>(); for (Post post : postAdapter.getList()) { if (post.hasImage) { imagePosts.add(post); } } // Setup our pages and adapter setContentView(R.layout.image_pager); viewPager = (ViewPager) findViewById(R.id.image_pager); adapter = new ImageViewAdapter(getFragmentManager(), this); adapter.setList(imagePosts); viewPager.setAdapter(adapter); viewPager.setOnPageChangeListener(this); // Select the right image for (int i = 0; i < imagePosts.size(); i++) { if (imagePosts.get(i).no == selectedId) { viewPager.setCurrentItem(i); onPageSelected(i); break; } } }
From source file:net.peterkuterna.android.apps.devoxxsched.ui.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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.// ww w . ja va 2 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 GridFragment. 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) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:com.yamin.kk.fragment.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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./*ww w. ja va 2 s . co 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 GridFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @SuppressWarnings("deprecation") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:org.yasik.android.app.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses can * override to replace with their own layout. If doing so, the returned view * hierarchy <em>must</em> have a GridView 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 ww. j a va 2 s . c om*/ * * <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 * GridFragment. 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) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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)); FrameLayout lframe = new FrameLayout(context); 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)); GridView lv = new GridView(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:by.istin.android.xcore.inherited.fragment.AdapterViewFragment.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. * /* ww w . j a va 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(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); 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)); AdapterView<?> adapterView = createDefaultAbstractView(); adapterView.setId(android.R.id.list); if (adapterView instanceof ListView) { ((ListView) adapterView).setDrawSelectorOnTop(false); } lframe.addView(adapterView, 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:ch.arnab.simplelauncher.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a GridView 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 grid 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. *//* w w w . j a va 2s . c om*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); 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)); GridView lv = new GridView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setColumnWidth(convertDpToPixels(60, getActivity())); lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); lv.setNumColumns(GridView.AUTO_FIT); lv.setHorizontalSpacing(convertDpToPixels(20, getActivity())); lv.setVerticalSpacing(convertDpToPixels(20, getActivity())); lv.setSmoothScrollbarEnabled(true); // disable overscroll if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER); } 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.imobile.mt8382hotkeydefine.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a GridView 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 grid 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. */// w w w . j a v a 2 s . c o m @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); 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)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); 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)); GridView lv = new GridView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setColumnWidth(convertDpToPixels(60, getActivity())); lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); lv.setNumColumns(GridView.AUTO_FIT); lv.setHorizontalSpacing(convertDpToPixels(20, getActivity())); lv.setVerticalSpacing(convertDpToPixels(20, getActivity())); lv.setSmoothScrollbarEnabled(true); // disable overscroll if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER); } 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; }