List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.hkm.uipack.ScrollView.QuickReturnFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(layout_fragment_content, container, false); mObservableScrollView = (ObservableScrollView) rootView.findViewById(scroll_view_id); mObservableScrollView.setCallbacks(this); mQuickReturnView = (TextView) rootView.findViewById(sticky_id); // mQuickReturnView.setText(R.string.quick_return_item); mPlaceholderView = rootView.findViewById(placeholder_id); mObservableScrollView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override/*from w w w . jav a 2s.co m*/ public void onGlobalLayout() { onScrollChanged(mObservableScrollView.getScrollY()); mMaxScrollY = mObservableScrollView.computeVerticalScrollRange() - mObservableScrollView.getHeight(); mQuickReturnHeight = mQuickReturnView.getHeight(); } }); return rootView; }
From source file:com.shopify.buy.ui.ProductImagePagerAdapter.java
@Override public View getView(final int pos, ViewPager pager) { Context context = pager.getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.view_product_image, pager, false); layout.setTag(pos);//from w w w. j a va 2 s.c om final View imageLoadingIndicator = layout.findViewById(R.id.image_loading_indicator); final ImageView imageView = (ImageView) layout.findViewById(R.id.image); if (bitmaps == null) { bitmaps = new Bitmap[images.size()]; Arrays.fill(bitmaps, null); } final boolean needBitmap = bitmaps[pos] == null; if (!needBitmap) { imageLoadingIndicator.setVisibility(View.INVISIBLE); imageView.setImageBitmap(bitmaps[pos]); } else { // We don't ask Picasso to show a placeholder because we want to scale the placeholder differently than // the product image. The placeholder should be displayed using CENTER_INSIDE, while the image should be // loaded using Picasso's fit() request method (to reduce memory usage during decoding) and then cropped // or fitted into the target view. String imageUrl = stripQueryFromUrl(images.get(pos).getSrc()); ImageUtility.loadRemoteImageIntoViewWithoutSize(Picasso.with(context), imageUrl, imageView, maxWidth, maxHeight, false, new Callback() { @Override public void onSuccess() { bitmaps[pos] = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); imageLoadingIndicator.setVisibility(View.INVISIBLE); addBackgroundColor(pos); } @Override public void onError() { imageLoadingIndicator.setVisibility(View.VISIBLE); } }); } return layout; }
From source file:com.giovanniterlingen.windesheim.view.Fragments.ContentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadPending); NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadUpdated); NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadFinished); final ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_contents, container, false); recyclerView = viewGroup.findViewById(R.id.contents_recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false); final ProgressBar progressBar = viewGroup.findViewById(R.id.progress_bar); progressBar.setVisibility(View.VISIBLE); Bundle bundle = this.getArguments(); ActionBar toolbar = ((NatschoolActivity) getActivity()).getSupportActionBar(); if (toolbar != null) { String studyRouteName;//from ww w . j a v a 2 s. co m if (bundle != null && (studyRouteName = bundle.getString(STUDYROUTE_NAME)) != null && studyRouteName.length() != 0) { toolbar.setTitle(bundle.getString(STUDYROUTE_NAME)); } else { toolbar.setTitle(getResources().getString(R.string.courses)); } toolbar.setDisplayHomeAsUpEnabled(false); toolbar.setDisplayHomeAsUpEnabled(true); } new NatSchoolController((bundle == null ? -1 : (studyRouteId = bundle.getInt(STUDYROUTE_ID))), (bundle == null ? -1 : bundle.getInt(PARENT_ID, -1)), getActivity()) { @Override public void onFinished(final List<NatschoolContent> courses) { progressBar.setVisibility(View.GONE); TextView emptyTextView = viewGroup.findViewById(R.id.empty_textview); if (courses.isEmpty()) { emptyTextView.setVisibility(View.VISIBLE); } else { emptyTextView.setVisibility(View.GONE); } adapter = new NatschoolContentAdapter(getActivity(), courses) { @Override protected void onContentClick(NatschoolContent content, int position) { if (content.url == null || content.url.length() == 0) { Bundle bundle = new Bundle(); if (content.id == -1) { bundle.putInt(STUDYROUTE_ID, content.studyRouteItemId); } else { bundle.putInt(STUDYROUTE_ID, studyRouteId); bundle.putInt(PARENT_ID, content.id); } bundle.putString(STUDYROUTE_NAME, content.name); ContentsFragment contentsFragment = new ContentsFragment(); contentsFragment.setArguments(bundle); getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.contents_fragment, contentsFragment, "").addToBackStack("") .commit(); } else { if (content.type == 1 || content.type == 3 || content.type == 11) { createWebView(content.url); } else if (content.type == 10) { if (!content.downloading) { new DownloadController(getActivity(), content.url, studyRouteId, content.id, position).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } } }; recyclerView.setAdapter(adapter); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return viewGroup; }
From source file:org.openintents.historify.ui.fragments.MainScreenFragment.java
/** Called to have the fragment instantiate its user interface view. */ @Override/*from w ww . ja v a2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.fragment_main_screen, container, false); // init list for contacts lstContacts = (HorizontalListView) layout.findViewById(R.id.main_screen_lstContacts); recentlyContactedAdapter = new RecentlyContactedAdapter(getActivity()); lstContacts.setAdapter(recentlyContactedAdapter); lstContacts.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, final View view, int pos, long id) { view.setBackgroundResource(R.drawable.bubble); view.postDelayed(new Runnable() { public void run() { view.setBackgroundDrawable(null); } }, 500); onContactClicked((Contact) adapterView.getItemAtPosition(pos)); } }); // init list empty view View viewContactListEmpty = layout.findViewById(R.id.main_screen_viewEmptyList); viewContactListEmpty.setVisibility(View.GONE); lstContacts.setEmptyView(viewContactListEmpty); // init buttons btnMore = (Button) layout.findViewById(R.id.main_screen_btnMore); btnFavorites = (Button) layout.findViewById(R.id.main_screen_btnFavorites); btnSources = (Button) layout.findViewById(R.id.btnSources); if (btnMore != null) { btnMore.setOnClickListener(new OnClickListener() { public void onClick(View v) { onMoreClicked(); } }); btnFavorites.setOnClickListener(new OnClickListener() { public void onClick(View v) { onFavoritesClicked(); } }); btnSources.setOnClickListener(new OnClickListener() { public void onClick(View v) { onSourcesClicked(); } }); } return layout; }
From source file:org.acdd.launcher.welcome.WelcomeFragment.java
@Override public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View imageView = null;//w ww .ja v a2s. c om // super.onCreate(bundle); this.mHandler = new Handler(this); ViewGroup viewGroup2 = (ViewGroup) layoutInflater.inflate(R.layout.welcome, viewGroup, false); final PathView pathView = (PathView) viewGroup2.findViewById(R.id.pathViewS); PathView pathViewJ = (PathView) viewGroup2.findViewById(R.id.pathViewJ); PathView pathViewT = (PathView) viewGroup2.findViewById(R.id.pathViewT); PathView pathViewB = (PathView) viewGroup2.findViewById(R.id.pathViewB); // final Path path = makeConvexArrow(50, 100); // pathView.setPath(path); Log.d("ver", Build.VERSION.SDK_INT + "<<<<<"); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) { pathView.setFillAfter(true); pathView.useNaturalColors(); pathView.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewJ.setFillAfter(true); pathViewJ.useNaturalColors(); pathViewJ.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewT.setFillAfter(true); pathViewT.useNaturalColors(); pathViewT.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); pathViewB.setFillAfter(true); pathViewB.useNaturalColors(); pathViewB.getPathAnimator().delay(100).duration(1500) .interpolator(new AccelerateDecelerateInterpolator()).start(); } init(); return viewGroup2; }
From source file:com.cyanogenmod.eleven.ui.fragments.PlaylistFragment.java
/** * {@inheritDoc}//from w w w. j a v a 2 s .c om */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.list_base, null); // Initialize the list mListView = (ListView) rootView.findViewById(R.id.list_base); // Set the data behind the grid mListView.setAdapter(mAdapter); // Release any references to the recycled Views mListView.setRecyclerListener(new RecycleHolder()); // Play the selected song mListView.setOnItemClickListener(this); // Setup the loading and empty state mLoadingEmptyContainer = (LoadingEmptyContainer) rootView.findViewById(R.id.loading_empty_container); mListView.setEmptyView(mLoadingEmptyContainer); // Register the music status listener ((BaseActivity) getActivity()).setMusicStateListenerListener(this); return rootView; }
From source file:com.racoon.ampdroid.views.CurrentPlaylistView.java
@SuppressLint("InflateParams") @Override/*from www .ja v a 2 s. c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { controller = Controller.getInstance(); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.current_playlist, null); playlist = (ListView) root.findViewById(R.id.playNow_listview); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { playlist.setFastScrollAlwaysVisible(true); } seekBar = (SeekBar) root.findViewById(R.id.playNow_seekbar); songTitle = (TextView) root.findViewById(R.id.playNow_song); songArtist = (TextView) root.findViewById(R.id.playNow_artist); duration = (TextView) root.findViewById(R.id.playNow_duration); currentDuration = (TextView) root.findViewById(R.id.playNow_duration_current); togglePlayButton = (ImageButton) root.findViewById(R.id.playlist_play_pause); ArrayList<String> list = new ArrayList<String>(); for (Song s : controller.getPlayNow()) { list.add(s.toString()); } Log.d("songs:", list.toString()); CurrentlyPlayingPlaylistArrayAdapter adapter = new CurrentlyPlayingPlaylistArrayAdapter( getActivity().getApplicationContext(), list, controller.getPlayNow()); playlist.setAdapter(adapter); playlist.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { try { MainActivity main = (MainActivity) getActivity(); main.play(position); updateSongData(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); updateSongData(); setHasOptionsMenu(true); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.news.NewsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new NewsItemAdapter(null); mRecyclerView.setAdapter(mAdapter);/*from w ww. jav a 2 s .c o m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(NewsViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getNewsItems().observe(this, newsItemValues -> { if (newsItemValues != null) { mEmptyView.setVisibility(View.GONE); mAdapter.setData(newsItemValues); } }); viewModel.refresh(); return root; }
From source file:com.infine.android.devoxx.ui.TwitterFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null); root.setLayoutParams(/*from w w w .j a v a 2 s . co m*/ new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mWebView = (WebView) root.findViewById(R.id.webview); mWebView.setWebViewClient(mWebViewClient); mWebView.post(new Runnable() { public void run() { mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); mWebView.loadUrl(UIUtils.CONFERENCE_HTTP_URL); } }); return root; }
From source file:net.peterkuterna.android.apps.devoxxsched.ui.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_map, null); mMapView = (MapView) root.findViewById(R.id.mapview); mMapView.setBuiltInZoomControls(true); mMapView.setSatellite(mSatellite);/*from www. j a v a 2 s . c om*/ mOverlays = mMapView.getOverlays(); mOverlays.add(new MetropolisOverlay()); mLevel0 = (Button) root.findViewById(R.id.level0); mLevel1 = (Button) root.findViewById(R.id.level1); mLevel0.setSelected(mLevel == 0); mLevel1.setSelected(mLevel == 1); mLevel0.setOnClickListener(mLevelClickListener); mLevel1.setOnClickListener(mLevelClickListener); Button satelliteBtn = (Button) root.findViewById(R.id.satellite); satelliteBtn.setSelected(mSatellite); satelliteBtn.setOnClickListener(mSatteliteClickListener); mMapController = mMapView.getController(); mMapController.setCenter(METROPOLIS_GEOPOINT); mMapController.setZoom(19); return root; }