List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.ksharkapps.musicnow.ui.fragments.phone.MusicBrowserPhoneFragment.java
/** * {@inheritDoc}/* w w w .j av a 2 s . c o m*/ */ @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.fragment_music_browser_phone, container, false); // Initialize the adapter mPagerAdapter = new PagerAdapter(getActivity()); final MusicFragments[] mFragments = MusicFragments.values(); for (final MusicFragments mFragment : mFragments) { mPagerAdapter.add(mFragment.getFragmentClass(), null); } // Initialize the ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.fragment_home_phone_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Start on the last page the user was on mViewPager.setCurrentItem(mPreferences.getStartPage()); // Initialze the TPI pageIndicator = (ScrollableTabView) rootView.findViewById(R.id.fragment_home_phone_pager_titles); // Attach the ViewPager ScrollingTabsAdapter mScrollingTabsAdapter = new ScrollingTabsAdapter(getActivity()); pageIndicator.setAdapter(mScrollingTabsAdapter); pageIndicator.setViewPager(mViewPager); return rootView; }
From source file:com.facebook.GraphObjectListFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }/*w ww . ja v a 2s .c om*/ doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(); } } }); if (doneButtonText == null) { doneButtonText = getDefaultDoneButtonText(); } if (doneButtonText != null) { doneButton.setText(doneButtonText); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (titleText == null) { titleText = getDefaultTitleText(); } if (titleText != null) { titleTextView.setText(titleText); } } } }
From source file:mobisocial.musubi.ui.widget.DbObjCursorAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { Cursor cursor = getCursor();/*from ww w .j a v a 2 s .com*/ if (!moveCursorToPosition(cursor, position)) { throw new IllegalStateException("couldn't move cursor to position " + position); } DbObjCursor row; if (convertView == null) { row = DbObjCursor.getInstance(mDbManager, cursor); } else { row = DbObjCursor.getInstance(mDbManager, cursor, (DbObjCursor) convertView.getTag(R.id.object_entry)); } FeedRenderer renderer = ObjHelpers.getFeedRenderer(row.type); ViewGroup objectMainView; ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); LayoutInflater inflater = LayoutInflater.from(mContext); objectMainView = (ViewGroup) inflater.inflate(R.layout.objects_item, parent, false); viewHolder.frame = (ViewGroup) objectMainView.findViewById(R.id.object_content); viewHolder.objView = renderer.createView(mContext, viewHolder.frame); viewHolder.frame.addView(viewHolder.objView); viewHolder.error = objectMainView.findViewById(R.id.error_text); viewHolder.senderIcon = (ImageView) objectMainView.findViewById(R.id.icon); viewHolder.senderName = (TextView) objectMainView.findViewById(R.id.name_text); viewHolder.timeText = (TextView) objectMainView.findViewById(R.id.time_text); viewHolder.sendingIcon = (ImageView) objectMainView.findViewById(R.id.sending_icon); viewHolder.attachmentsIcon = (ImageView) objectMainView.findViewById(R.id.obj_attachments_icon); viewHolder.attachmentsText = (TextView) objectMainView.findViewById(R.id.obj_attachments); viewHolder.addContact = (TextView) objectMainView.findViewById(R.id.add_contact); objectMainView.setTag(R.id.holder, viewHolder); objectMainView.setTag(R.id.object_entry, row); } else { objectMainView = (ViewGroup) convertView; viewHolder = (ViewHolder) objectMainView.getTag(R.id.holder); } ObjHelpers.bindObjViewFrame(mContext, mDbManager, objectMainView, viewHolder, row); boolean allowInteractions = true; try { renderer.render(mContext, viewHolder.objView, row, allowInteractions); viewHolder.error.setVisibility(View.GONE); viewHolder.frame.setVisibility(View.VISIBLE); } catch (Exception e) { viewHolder.error.setVisibility(View.VISIBLE); viewHolder.frame.setVisibility(View.GONE); Log.e(getClass().getSimpleName(), "Error rendering type " + row.type, e); } return objectMainView; }
From source file:com.andrew.apollo.ui.fragments.phone.MusicBrowserPhoneFragment.java
/** * {@inheritDoc}//from w ww .j ava2 s. com */ @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.fragment_music_browser_phone, container, false); // Initialize the adapter mPagerAdapter = new PagerAdapter(getSherlockActivity()); final MusicFragments[] mFragments = MusicFragments.values(); for (final MusicFragments mFragment : mFragments) { mPagerAdapter.add(mFragment.getFragmentClass(), null); } // Initialize the ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.fragment_home_phone_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Start on the last page the user was on mViewPager.setCurrentItem(mPreferences.getStartPage()); // Initialze the TPI final TitlePageIndicator pageIndicator = (TitlePageIndicator) rootView .findViewById(R.id.fragment_home_phone_pager_titles); // Attach the ViewPager pageIndicator.setViewPager(mViewPager); // Scroll to the current artist, album, or song pageIndicator.setOnCenterItemClickListener(this); return rootView; }
From source file:com.achep.acdisplay.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.acdisplay_scene_music, container, false); assert sceneView != null; }/*from ww w. ja va2 s. c om*/ mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()).inflate(getMenuItemLayoutId(), this, false);//ww w. java 2 s.co m FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); if (miniFabTitleTextColorArray != null) { titleView.setTextColor(ContextCompat.getColorStateList(getContext(), miniFabTitleTextColorArray[menuItem.getOrder()])); } } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (miniFabBackgroundTintArray != null) { miniFab.setBackgroundTintList( ContextCompat.getColorStateList(getContext(), miniFabBackgroundTintArray[menuItem.getOrder()])); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
From source file:com.google.android.apps.iosched.ui.SessionDetailFragment.java
private void updateLinksTab(Cursor cursor) { ViewGroup container = (ViewGroup) mRootView.findViewById(R.id.links_container); // Remove all views but the 'empty' view int childCount = container.getChildCount(); if (childCount > 1) { container.removeViews(1, childCount - 1); }//from ww w. ja va 2 s.c o m LayoutInflater inflater = getLayoutInflater(null); boolean hasLinks = false; for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String url = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (!TextUtils.isEmpty(url)) { hasLinks = true; ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, container, false); ((TextView) linkContainer.findViewById(R.id.link_text)).setText(SessionsQuery.LINKS_TITLES[i]); final int linkTitleIndex = i; linkContainer.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); } }); container.addView(linkContainer); // Create separator View separatorView = new ImageView(getActivity()); separatorView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); separatorView.setBackgroundResource(android.R.drawable.divider_horizontal_bright); container.addView(separatorView); } } container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE); }
From source file:com.bullmobi.message.ui.components.MediaWidget.java
@Override protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable ViewGroup sceneView) { boolean initialize = sceneView == null; if (initialize) { sceneView = (ViewGroup) inflater.inflate(R.layout.easynotification_scene_music, container, false); assert sceneView != null; }/*from w w w.ja v a 2 s. co m*/ mArtworkView = (ImageView) sceneView.findViewById(R.id.artwork); ViewGroup infoLayout = (ViewGroup) sceneView.findViewById(R.id.metadata); mTitleView = (TextView) infoLayout.findViewById(R.id.media_title); mSubtitleView = (TextView) infoLayout.findViewById(R.id.media_subtitle); mButtonPrevious = (ImageButton) sceneView.findViewById(R.id.previous); mButtonPlayPause = (ImageButton) sceneView.findViewById(R.id.play); mButtonNext = (ImageButton) sceneView.findViewById(R.id.next); mSeekLayout = (ViewGroup) sceneView.findViewById(R.id.seek_layout); mSeekBar = (SeekBar) mSeekLayout.findViewById(R.id.seek_bar); mPositionText = (TextView) mSeekLayout.findViewById(R.id.playback_position); mDurationText = (TextView) mSeekLayout.findViewById(R.id.duration); if (!initialize) { return sceneView; } mSeekBar.setOnSeekBarChangeListener(this); mButtonPrevious.setOnClickListener(this); mButtonPlayPause.setImageDrawable(mPlayPauseDrawable); mButtonPlayPause.setOnClickListener(this); mButtonPlayPause.setOnLongClickListener(this); mButtonNext.setOnClickListener(this); // Show the seek-panel on long click. infoLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Don't allow seeking on a weird song. if (mMediaController.getMetadata().duration <= 0 || mMediaController.getPlaybackPosition() < 0) { if (mSeekUiAtomic.isRunning()) { toggleSeekUiVisibility(); return true; } return false; } toggleSeekUiVisibility(); return true; } private void toggleSeekUiVisibility() { ViewGroup vg = getView(); if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) { TransitionManager.beginDelayedTransition(vg); } mSeekUiAtomic.react(!mSeekUiAtomic.isRunning()); mCallback.requestTimeoutRestart(MediaWidget.this); } }); if (Device.hasLollipopApi()) { // FIXME: Ripple doesn't work if the background is set (masked ripple works fine, but ugly). // Apply our own ripple drawable with slightly extended abilities, such // as setting color filter. ColorStateList csl = container.getResources().getColorStateList(R.color.ripple_dark); mButtonPlayPause.setBackground(new RippleDrawable2(csl, null, null)); } else { RippleUtils.makeFor(false, true, mButtonNext, mButtonPlayPause, mButtonPrevious); } updatePlayPauseButtonColor(mArtworkColor); updateSeekBarColor(mArtworkColor); return sceneView; }
From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. */// w w w.jav a 2 s . c o m private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); mRoomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, mRoomName, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0)); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } mPlusOneButton.setSize(PlusOneButton.Size.TALL); String url = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(url)) { mPlusOneButton.setVisibility(View.GONE); } else { mPlusOneButton.setUrl(url); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } ViewGroup linksContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linksContainer.removeAllViews(); LayoutInflater inflater = getLayoutInflater(null); boolean hasLinks = false; final Context context = mRootView.getContext(); // Render I/O live link final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL)); long currentTimeMillis = UIUtils.getCurrentTime(context); if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream && hasLivestream && currentTimeMillis > mSessionBlockStart && currentTimeMillis <= mSessionBlockEnd) { hasLinks = true; // Create the link item ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, linksContainer, false); ((TextView) linkContainer.findViewById(R.id.link_text)).setText(R.string.session_link_livestream); linkContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(R.string.session_link_livestream); Intent livestreamIntent = new Intent(Intent.ACTION_VIEW, mSessionUri); livestreamIntent.setClass(context, SessionLivestreamActivity.class); startActivity(livestreamIntent); } }); linksContainer.addView(linkContainer); } // Render normal links for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (!TextUtils.isEmpty(linkUrl)) { hasLinks = true; // Create the link item ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, linksContainer, false); ((TextView) linkContainer.findViewById(R.id.link_text)).setText(SessionsQuery.LINKS_TITLES[i]); final int linkTitleIndex = i; linkContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.safeOpenLink(context, intent); } }); linksContainer.addView(linkContainer); } } // Show past/present/future and livestream status for this block. UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null, null, mSubtitle, subtitle); mRootView.findViewById(R.id.session_links_block).setVisibility(hasLinks ? View.VISIBLE : View.GONE); EasyTracker.getTracker().trackView("Session: " + mTitleString); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.facebook.GraphObjectListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(layout, container, false); listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from w ww . j av a 2 s .c om*/ public void onItemClick(AdapterView<?> parent, View v, int position, long id) { onListItemClick((ListView) parent, v, position); } }); listView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // We don't actually do anything differently on long-clicks, but setting the listener // enables the selector transition that we have for visual consistency with the // Facebook app's pickers. return false; } }); listView.setOnScrollListener(onScrollListener); listView.setAdapter(adapter); activityCircle = (ProgressBar) view.findViewById(R.id.com_facebook_picker_activity_circle); return view; }