List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.geecko.QuickLyric.AboutActivity.java
private void setupDemoScreen() { ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content).getRootView(); getLayoutInflater().inflate(R.layout.tutorial_view, (ViewGroup) rootView.getChildAt(0)); final ViewPager pager = (ViewPager) findViewById(R.id.pager); CirclePageIndicator indicator = (CirclePageIndicator) findViewById(R.id.indicator); final IntroScreenSlidePagerAdapter pagerAdapter = new IntroScreenSlidePagerAdapter(getFragmentManager(), this); pager.setAdapter(pagerAdapter);//from ww w. ja v a2 s . c om pager.addOnPageChangeListener(pagerAdapter); indicator.setViewPager(pager); pager.setCurrentItem(pagerAdapter.rightToLeft ? pagerAdapter.getCount() - 1 : 0); indicator.setOnPageChangeListener(pagerAdapter); Button skipButton = (Button) rootView.findViewById(R.id.pager_button); ImageButton arrowButton = (ImageButton) rootView.findViewById(R.id.pager_arrow); skipButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) pagerAdapter.exitAction(); else pager.setCurrentItem(pagerAdapter.getCount() - 1); } }); arrowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pagerAdapter.nextAction(); } }); }
From source file:com.cairoconfessions.MainActivity.java
public View addConfession(String confess, String desc) { final ViewGroup confession = (ViewGroup) LayoutInflater.from(this) .inflate(R.layout.confession_list_item_example, null); final TextView newConfess = (TextView) confession.findViewById(R.id.text_main); newConfess.setText(confess);/* www . ja va 2 s . com*/ final float scale = getResources().getDisplayMetrics().density; if (!desc.equals("")) { confession.setContentDescription(desc); if (desc.equals("Love")) newConfess.setBackgroundResource(R.color.love); if (desc.equals("Pain")) newConfess.setBackgroundResource(R.color.pain); if (desc.equals("Guilt")) newConfess.setBackgroundResource(R.color.guilt); if (desc.equals("Fantasy")) newConfess.setBackgroundResource(R.color.fantasy); if (desc.equals("Dream")) newConfess.setBackgroundResource(R.color.dream); } else { switch ((new Random().nextInt(5)) % 5) { case 0: newConfess.setBackgroundResource(R.color.love); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); confession.setContentDescription("Love"); break; case 1: newConfess.setBackgroundResource(R.color.pain); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo"); confession.setContentDescription("Pain"); break; case 2: newConfess.setBackgroundResource(R.color.guilt); ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); confession.setContentDescription("Guilt"); break; case 3: newConfess.setBackgroundResource(R.color.fantasy); ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); confession.setContentDescription("Fantasy"); break; case 4: newConfess.setBackgroundResource(R.color.dream); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); confession.setContentDescription("Dream"); break; } } switch ((new Random().nextInt(3)) % 3) { case 0: ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); break; case 1: ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo"); break; case 2: ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); break; } Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setDuration(1000); confession.setAnimation(fadeIn); confession.getChildAt(0).setPadding((int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f)); confession.getChildAt(0).setBackgroundResource(R.drawable.border); mPager.setCurrentItem(1); if (!desc.equals("")) { ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP); ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0); } else { new Timer().schedule(new TimerTask() { @Override public void run() { ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP); ((LinearLayout) findViewById(R.id.confession_list)).post(new Runnable() { public void run() { ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0); } }); } }, 1000); } return confession; }
From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.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); }// ww w . j a v a2 s . com LayoutInflater inflater = getLayoutInflater(null); boolean hasLinks = false; container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE); }
From source file:li.barter.fragments.NavDrawerFragment.java
/** * Initialize the profile header views. Reads the references to the child views and stores them * as tags//from ww w . ja v a 2 s . c o m */ private void initProfileHeaderViews() { //Get references to the two primary containers final ViewGroup profileContainer = (ViewGroup) mProfileHeader.findViewById(R.id.container_profile_info); mProfileHeader.setTag(R.id.container_profile_info, profileContainer); final ViewGroup signInContainer = (ViewGroup) mProfileHeader.findViewById(R.id.container_sign_in_message); mProfileHeader.setTag(R.id.container_sign_in_message, signInContainer); //Get references to the individual container children and set tags profileContainer.setTag(R.id.text_user_name, profileContainer.findViewById(R.id.text_user_name)); profileContainer.setTag(R.id.image_user, profileContainer.findViewById(R.id.image_user)); TextView textView = (TextView) signInContainer.findViewById(R.id.text_nav_item_title); textView.setText(R.string.text_sign_in); signInContainer.setTag(R.id.text_nav_item_title, textView); }
From source file:com.cw.litenote.note.NoteUi.java
/** * Set picture view listeners//w w w. ja v a 2 s . c o m * @param act * @param pager * @param strPicture * @param linkUri * @param viewGroup */ private void setPictureView_listeners(final AppCompatActivity act, final ViewPager pager, final String strPicture, final String linkUri, ViewGroup viewGroup) { System.out.println("NoteUi / setPictureView_listeners"); Button picView_back_button = (Button) (viewGroup.findViewById(R.id.image_view_back)); Button picView_viewMode_button = (Button) (viewGroup.findViewById(R.id.image_view_mode)); Button picView_previous_button = (Button) (viewGroup.findViewById(R.id.image_view_previous)); Button picView_next_button = (Button) (viewGroup.findViewById(R.id.image_view_next)); Button mVideoPlayButton = (Button) (viewGroup.findViewById(R.id.video_view_play_video)); final TextView videoView_currPosition = (TextView) (viewGroup.findViewById(R.id.video_current_pos)); SeekBar videoView_seekBar = (SeekBar) (viewGroup.findViewById(R.id.video_seek_bar)); // Set video play button listener if (UtilVideo.hasVideoExtension(strPicture, act)) { mVideoPlayButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { System.out.println("NoteUi / setPictureView_listeners / mVideoPlayButton / getVideoState() = " + UtilVideo.getVideoState()); if ((BackgroundAudioService.mMediaPlayer != null) && (Audio_manager.getPlayerState() != Audio_manager.PLAYER_AT_STOP) && (UtilVideo.getVideoState() != UtilVideo.VIDEO_AT_PLAY)) { // Dialog: confirm to disable audio or not AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(R.string.title_playing_audio).setMessage(R.string.message_continue_or_stop) .setPositiveButton(R.string.btn_Stop, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Audio_manager.stopAudioPlayer(); UtilVideo.changeVideoState(); UtilVideo.playOrPauseVideo(pager, strPicture); } }).setNegativeButton(R.string.btn_Continue, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { UtilVideo.changeVideoState(); UtilVideo.playOrPauseVideo(pager, strPicture); } }).show(); } else { UtilVideo.changeVideoState(); UtilVideo.playOrPauseVideo(pager, strPicture); updateVideoPlayButtonState(pager, getFocus_notePos()); } } }); } else if (Util.isYouTubeLink(linkUri)) { mVideoPlayButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_media_play, 0, 0, 0); mVideoPlayButton.setVisibility(View.VISIBLE); // set listener for running YouTube mVideoPlayButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { System.out.println( "NoteUi / _setPictureView_listeners / onClick to play YouTube / linkUri = " + linkUri); // apply native YouTube // Util.openLink_YouTube(act, linkUri); // apply YouTube DATA API for note view Intent intent = new Intent(act, YouTubePlayerAct.class); act.startActivityForResult(intent, Util.YOUTUBE_LINK_INTENT); } }); } else if (Util.isEmptyString(strPicture) && linkUri.startsWith("http") && !UtilImage.hasImageExtension(linkUri, act) && //filter: some link has image extension Note.isViewAllMode()) { // set listener for running browser if (viewGroup != null) { CustomWebView linkWebView = ((CustomWebView) viewGroup.findViewById(R.id.link_web_view)); linkWebView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUri)); act.startActivity(i); } return true; } }); } } // view mode // picture only if (Note.isPictureMode()) { // image: view back picView_back_button.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_menu_back /*android.R.drawable.ic_menu_revert*/, 0, 0, 0); // click to finish Note_view_pager picView_back_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // remove current link web view int position = getFocus_notePos(); String tagPictureStr = "current" + position + "pictureView"; ViewGroup pictureGroup = (ViewGroup) pager.findViewWithTag(tagPictureStr); if (pictureGroup != null) { CustomWebView linkWebView = ((CustomWebView) pictureGroup.findViewById(R.id.link_web_view)); CustomWebView.pauseWebView(linkWebView); CustomWebView.blankWebView(linkWebView); } // set not full screen Util.setFullScreen_noImmersive(act); // back to view all mode Note.setViewAllMode(); Note.setOutline(act); } }); // image: view mode picView_viewMode_button.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_view, 0, 0, 0); // click to select view mode picView_viewMode_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { TextView audio_title_text_view = (TextView) act.findViewById(R.id.pager_audio_title); audio_title_text_view.setSelected(false); //Creating the instance of PopupMenu popup = new PopupMenu(act, view); //Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.pop_up_menu, popup.getMenu()); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.view_all: Note.setViewAllMode(); Note.setOutline(act); break; case R.id.view_picture: Note.setPictureMode(); Note.setOutline(act); break; case R.id.view_text: Note.setTextMode(); Note.setOutline(act); break; } return true; } }); popup.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { TextView audio_title_text_view = (TextView) act.findViewById(R.id.pager_audio_title); if (BackgroundAudioService.mMediaPlayer != null) { if (BackgroundAudioService.mMediaPlayer.isPlaying()) { AudioUi_note.showAudioName(act); audio_title_text_view.setSelected(true); } } else audio_title_text_view.setSelected(false); } }); popup.show();//showing pop up menu, will show status bar // for transient popup cancel_UI_callbacks(); Note_adapter.picUI_primary = new NoteUi(act, pager, pager.getCurrentItem()); Note_adapter.picUI_primary.tempShow_picViewUI(5005, strPicture); } }); // image: previous button picView_previous_button.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_media_previous, 0, 0, 0); // click to previous picView_previous_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setFocus_notePos(getFocus_notePos() - 1); pager.setCurrentItem(pager.getCurrentItem() - 1); } }); // image: next button picView_next_button.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_media_next, 0, 0, 0); // click to next picView_next_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setFocus_notePos(getFocus_notePos() + 1); pager.setCurrentItem(pager.getCurrentItem() + 1); } }); } // video view: apply media control customization or not if (Note.isPictureMode() || Note.isViewAllMode()) { if (!UtilVideo.hasMediaControlWidget) { // set video seek bar listener videoView_seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { // onStartTrackingTouch @Override public void onStartTrackingTouch(SeekBar seekBar) { System.out.println("NoteUi / _onStartTrackingTouch"); if ((UtilVideo.mVideoPlayer == null) && (UtilVideo.mVideoView != null)) { if (Build.VERSION.SDK_INT >= 16) UtilVideo.mVideoView.setBackground(null); else UtilVideo.mVideoView.setBackgroundDrawable(null); UtilVideo.mVideoView.setVisibility(View.VISIBLE); UtilVideo.mVideoPlayer = new VideoPlayer(act, pager, strPicture); UtilVideo.mVideoView.seekTo(UtilVideo.mPlayVideoPosition); } } // onProgressChanged @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { System.out.println("NoteUi / _onProgressChanged"); if (fromUser) { // show progress change int currentPos = videoFileLength_inMilliSeconds * progress / (seekBar.getMax() + 1); // update current play time videoView_currPosition.setText(Util.getTimeFormatString(currentPos)); //add below to keep showing seek bar if (Note.isPictureMode()) show_picViewUI_previous_next(true, mPosition); showSeekBarProgress = true; if (handler != null) handler.removeCallbacks(runnableHideUi); tempShow_picViewUI(3001, strPicture); // for 3 seconds, _onProgressChanged } } // onStopTrackingTouch @Override public void onStopTrackingTouch(SeekBar seekBar) { System.out.println("NoteUi / _onStopTrackingTouch"); if (UtilVideo.mVideoView != null) { int mPlayVideoPosition = (int) (((float) (videoFileLength_inMilliSeconds / 100)) * seekBar.getProgress()); if (UtilVideo.mVideoPlayer != null) UtilVideo.mVideoView.seekTo(mPlayVideoPosition); if (handler != null) handler.removeCallbacks(runnableHideUi); tempShow_picViewUI(3002, strPicture); // for 3 seconds, _onProgressChanged } } }); } } }
From source file:com.activiti.android.ui.form.FormManager.java
protected void generateForm(LayoutInflater li, boolean isEdition) { boolean hasTab = false; if (!version.is120OrAbove()) { generateForm11(li, isEdition);//from w ww.ja v a 2 s. co m return; } ViewGroup rootView; // Generate Tabs if (data.getTabs() != null && !data.getTabs().isEmpty()) { rootView = (ViewGroup) li.inflate(R.layout.form_root_tabs, null); hasTab = true; tabLayout = (TabLayout) rootView.findViewById(R.id.task_form_tabs_container); tabLayout.setVisibility(View.VISIBLE); tabHookViewIndex = new HashMap<>(data.getTabs().size()); formTabFieldIndex = new LinkedHashMap<>(data.getTabs().size()); int i = 0; for (FormTabRepresentation tabRepresentation : data.getTabs()) { TabLayout.Tab tab = tabLayout.newTab().setText(tabRepresentation.getTitle()) .setTag(tabRepresentation.getId()); tabLayout.addTab(tab); ViewGroup tabHookView = (ViewGroup) li.inflate(R.layout.form_tab_children, null); tabHookViewIndex.put(tabRepresentation.getId(), tabHookView); tabHookView.setVisibility(View.GONE); rootView.addView(tabHookView); formTabFieldIndex.put(tabRepresentation.getId(), new TabField(tab, tabRepresentation, i, tabHookView)); i++; } tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.VISIBLE); } @Override public void onTabUnselected(TabLayout.Tab tab) { formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.GONE); } @Override public void onTabReselected(TabLayout.Tab tab) { formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.VISIBLE); } }); tabLayout.getTabAt(0).select(); } else { rootView = (ViewGroup) li.inflate(R.layout.form_root, null); } ViewGroup hookView = rootView; fieldsIndex = new HashMap<>(data.getFields().size()); // Generate Fields ViewGroup groupRoot = null; BaseField field; for (FormFieldRepresentation fieldData : data.getFields()) { if (FormFieldTypes.GROUP.equals(fieldData.getType())) { if (groupRoot != null) { rootView.addView(groupRoot); } // Header field = generateField(fieldData, rootView, isEdition); groupRoot = null; if (fieldData instanceof ContainerRepresentation) { // Create groupView if (groupRoot == null) { groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null); } if (hasTab && fieldData.getTab() != null) { hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab()) .findViewById(R.id.tab_group_container); } else { hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container); } Map<String, List<FormFieldRepresentation>> fields = ((ContainerRepresentation) fieldData) .getFields(); for (Map.Entry<String, List<FormFieldRepresentation>> entry : fields.entrySet()) { for (FormFieldRepresentation representation : entry.getValue()) { formFieldIndex.put(representation.getId(), representation); field = generateField(representation, hookView, isEdition); fieldsOrderIndex.add(field); fieldsIndex.put(representation.getId(), field); // Mark All fields in edition mode if (isEdition) { // Mark required Field if (representation.isRequired()) { mandatoryFields.add(field); } if (representation instanceof RestFieldRepresentation) { field.setFragment(fr); } } // If requires fragment for pickers. if (field.isPickerRequired()) { field.setFragment(fr); } } } } } else if (FormFieldTypes.CONTAINER.equals(fieldData.getType())) { // Create groupView if (groupRoot == null) { groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null); } if (hasTab && fieldData.getTab() != null) { hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab()) .findViewById(R.id.tab_group_container); } else { hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container); } Map<String, List<FormFieldRepresentation>> fields = ((ContainerRepresentation) fieldData) .getFields(); for (Map.Entry<String, List<FormFieldRepresentation>> entry : fields.entrySet()) { for (FormFieldRepresentation representation : entry.getValue()) { field = generateField(representation, hookView, isEdition); fieldsOrderIndex.add(field); fieldsIndex.put(representation.getId(), field); // Mark All fields in edition mode if (isEdition) { // Mark required Field if (representation.isRequired()) { mandatoryFields.add(field); } if (representation instanceof RestFieldRepresentation) { field.setFragment(fr); } } // If requires fragment for pickers. if (field.isPickerRequired()) { field.setFragment(fr); } } } } else if (FormFieldTypes.DYNAMIC_TABLE.equals(fieldData.getType()) || (FormFieldTypes.READONLY.equals(fieldData.getType()) && fieldData.getParams().get("field") != null && (FormFieldTypes.DYNAMIC_TABLE.toString() .equals(((HashMap) fieldData.getParams().get("field")).get("type"))))) { // Create groupView if (groupRoot == null) { groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null); } if (hasTab && fieldData.getTab() != null) { hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab()) .findViewById(R.id.tab_group_container); } else { hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container); } if (fieldData instanceof DynamicTableRepresentation) { field = generateField(fieldData, hookView, isEdition); fieldsOrderIndex.add(field); continue; } } } // Now time to evaluate everyone evaluateViews(); // Add Container to root ? if (groupRoot != null) { rootView.addView(groupRoot); } vRoot.addView(rootView); // OUTCOME if (!isEdition) { return; } View vr; if (data.getOutcomes() == null || data.getOutcomes().size() == 0) { outcomeIndex = new HashMap<>(1); vr = generateOutcome(rootView, getActivity().getString(R.string.form_default_outcome_complete), li); outcomeIndex.put(getActivity().getString(R.string.form_default_outcome_complete), vr); } else { outcomeIndex = new HashMap<>(data.getOutcomes().size()); for (FormOutcomeRepresentation outcomeData : data.getOutcomes()) { vr = generateOutcome(rootView, outcomeData.getName(), li); outcomeIndex.put(outcomeData.getName(), vr); } } }
From source file:de.gebatzens.ggvertretungsplan.fragment.MensaFragment.java
@Override public void createView(LayoutInflater inflater, ViewGroup view) { Display display = ((WindowManager) getActivity().getApplicationContext() .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); Log.d("Screen orientation", String.valueOf(rotation)); if ((rotation == 3) || (rotation == 1)) { screen_orientation_horizotal = true; } else {/*from w w w . ja va 2 s . com*/ screen_orientation_horizotal = false; } final ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("mensa_scroll"); ((LinearLayout) view.findViewById(R.id.mensa_content)).addView(sv); final LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); int p = toPixels(6); l.setPadding(p, p, p, p); sv.addView(l); for (Mensa.MensaItem item : GGApp.GG_APP.mensa) { if (!item.isPast()) l.addView(createCardItem(item, inflater)); } }
From source file:com.github.google.beaconfig.BeaconConfigActivity.java
/** * Displays a screen with a message and a "try again" button. Pressing the button will attempt * to connect to the beacon from beginning * * @param message message which we want to be printed on the screen *//*from ww w. j a v a 2 s.c o m*/ private void displayConnectionFailScreen(final String message) { runOnUiThread(new Runnable() { @Override public void run() { enableDisplay(); ViewGroup configContentView = (ViewGroup) findViewById(R.id.beacon_config_page_content); UiUtils.makeChildrenInvisible(configContentView); ViewGroup connectionFailSlot = (ViewGroup) findViewById(R.id.connection_fail); connectionFailSlot.findViewById(R.id.connection_fail_btn) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { accessBeacon(); findViewById(R.id.connection_fail).setVisibility(View.GONE); } }); ((TextView) connectionFailSlot.findViewById(R.id.connection_fail_message)).setText(message); connectionFailSlot.setVisibility(View.VISIBLE); } }); }
From source file:koma.movieapp.ui.MoviesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_movies, container, false); mCollectionView = (CollectionView) root.findViewById(R.id.movies_collection_view); mPreloader = new Preloader(ROWS_TO_PRELOAD); mCollectionView.setOnScrollListener(mPreloader); mEmptyView = (TextView) root.findViewById(R.id.empty_text); mLoadingView = root.findViewById(R.id.loading); return root;/*from w ww . j av a 2s . c o m*/ }
From source file:com.tct.mail.browse.ConversationItemViewCoordinates.java
private ConversationItemViewCoordinates(final Context context, final Config config, final CoordinatesCache cache) { Utils.traceBeginSection("CIV coordinates constructor"); final Resources res = context.getResources(); mMinListWidthForWide = res.getDimensionPixelSize(R.dimen.list_min_width_is_wide); mMode = calculateMode(res, config);/*from ww w. j ava 2s . c om*/ final int layoutId = R.layout.conversation_item_view; ViewGroup view = (ViewGroup) cache.getView(layoutId); if (view == null) { view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null); cache.put(layoutId, view); } // Show/hide optional views before measure/layout call final TextView folders = (TextView) view.findViewById(R.id.folders); folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE); View contactImagesView = view.findViewById(R.id.contact_image); switch (config.getGadgetMode()) { case GADGET_CONTACT_PHOTO: contactImagesView.setVisibility(View.VISIBLE); break; case GADGET_CHECKBOX: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; default: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; } final View replyState = view.findViewById(R.id.reply_state); replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE); final View personalIndicator = view.findViewById(R.id.personal_indicator); personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE); setFramePadding(context, view, config.useFullPadding()); // Layout the appropriate view. ViewCompat.setLayoutDirection(view, config.getLayoutDirection()); final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY); final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); view.measure(widthSpec, heightSpec); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); // Once the view is measured, let's calculate the dynamic width variables. folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0); folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion) / 100.0); // Utils.dumpViewTree((ViewGroup) view); // Records coordinates. // Contact images view if (contactImagesView != null) { contactImagesWidth = contactImagesView.getWidth(); contactImagesHeight = contactImagesView.getHeight(); contactImagesX = getX(contactImagesView); contactImagesY = getY(contactImagesView); } else { contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0; } final boolean isRtl = ViewUtils.isViewRtl(view); final View star = view.findViewById(R.id.star); final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start); starX = getX(star) + (isRtl ? 0 : starPadding); starY = getY(star); starWidth = star.getWidth(); final TextView senders = (TextView) view.findViewById(R.id.senders); final int sendersTopAdjust = getLatinTopAdjustment(senders); sendersX = getX(senders); sendersY = getY(senders) + sendersTopAdjust; sendersWidth = senders.getWidth(); sendersHeight = senders.getHeight(); sendersLineCount = SINGLE_LINE; sendersFontSize = senders.getTextSize(); final TextView subject = (TextView) view.findViewById(R.id.subject); final int subjectTopAdjust = getLatinTopAdjustment(subject); subjectX = getX(subject); subjectY = getY(subject) + subjectTopAdjust; subjectWidth = subject.getWidth(); subjectHeight = subject.getHeight(); subjectFontSize = subject.getTextSize(); // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_S final TextView status = (TextView) view.findViewById(R.id.status); final int statusTopAdjust = getLatinTopAdjustment(status); statusX = getX(status); statusY = getY(status) + statusTopAdjust; statusWidth = status.getWidth(); statusHeight = status.getHeight(); statusFontSize = status.getTextSize(); statusPaddingStart = ViewUtils.getPaddingStart(status); statusPanddingEnd = ViewUtils.getPaddingEnd(status); // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_E final TextView snippet = (TextView) view.findViewById(R.id.snippet); final int snippetTopAdjust = getLatinTopAdjustment(snippet); snippetX = getX(snippet); snippetY = getY(snippet) + snippetTopAdjust; maxSnippetWidth = snippet.getWidth(); snippetHeight = snippet.getHeight(); snippetFontSize = snippet.getTextSize(); if (config.areFoldersVisible()) { // vertically align folders min left edge with subject foldersLeft = getX(folders); foldersRight = foldersLeft + folders.getWidth(); foldersY = getY(folders) + sendersTopAdjust; foldersHeight = folders.getHeight(); foldersTypeface = folders.getTypeface(); foldersTextBottomPadding = res.getDimensionPixelSize(R.dimen.folders_text_bottom_padding); foldersFontSize = folders.getTextSize(); } else { foldersLeft = 0; foldersRight = 0; foldersY = 0; foldersHeight = 0; foldersTypeface = null; foldersTextBottomPadding = 0; foldersFontSize = 0; } final View colorBlock = view.findViewById(R.id.color_block); if (config.isColorBlockVisible() && colorBlock != null) { colorBlockX = getX(colorBlock); colorBlockY = getY(colorBlock); colorBlockWidth = colorBlock.getWidth(); colorBlockHeight = colorBlock.getHeight(); } else { colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0; } if (config.isReplyStateVisible()) { replyStateX = getX(replyState); replyStateY = getY(replyState); } else { replyStateX = replyStateY = 0; } if (config.isPersonalIndicatorVisible()) { personalIndicatorX = getX(personalIndicator); personalIndicatorY = getY(personalIndicator); } else { personalIndicatorX = personalIndicatorY = 0; } final View infoIcon = view.findViewById(R.id.info_icon); infoIconX = getX(infoIcon); infoIconXRight = infoIconX + infoIcon.getWidth(); infoIconY = getY(infoIcon); final TextView date = (TextView) view.findViewById(R.id.date); dateX = getX(date); dateXRight = dateX + date.getWidth(); dateY = getY(date); datePaddingStart = ViewUtils.getPaddingStart(date); dateFontSize = date.getTextSize(); dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline(); final View paperclip = view.findViewById(R.id.paperclip); paperclipY = getY(paperclip); paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip); height = view.getHeight() + sendersTopAdjust; Utils.traceEndSection(); }