List of usage examples for android.widget FrameLayout setId
public void setId(@IdRes int id)
From source file:com.xamoom.android.xamoomcontentblocks.ViewHolders.ContentBlock2ViewHolder.java
private void setupYoutube(final ContentBlock contentBlock) { final String youtubeVideoId = getYoutubeVideoId(contentBlock.getVideoUrl()); Bitmap savedBitmap = mBitmapCache.get(youtubeVideoId); if (savedBitmap != null) { mProgressBar.setVisibility(View.GONE); mYouTubeThumbnailView.setImageBitmap(savedBitmap); } else {//from ww w. jav a 2s . c o m mYouTubeThumbnailView.initialize(mYoutubeApiKey, new YouTubeThumbnailView.OnInitializedListener() { @Override public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, final YouTubeThumbnailLoader youTubeThumbnailLoader) { youTubeThumbnailLoader.setVideo(youtubeVideoId); youTubeThumbnailLoader .setOnThumbnailLoadedListener(new YouTubeThumbnailLoader.OnThumbnailLoadedListener() { @Override public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) { mProgressBar.setVisibility(View.GONE); Drawable drawable = mYouTubeThumbnailView.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; mBitmapCache.put(youtubeVideoId, bitmapDrawable.getBitmap()); } youTubeThumbnailLoader.release(); } @Override public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) { youTubeThumbnailView.setBackgroundColor(Color.BLACK); mProgressBar.setVisibility(View.GONE); youtubeFallback(contentBlock.getVideoUrl()); youTubeThumbnailLoader.release(); } }); } @Override public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) { mProgressBar.setVisibility(View.GONE); mVideoPlayImageView.setVisibility(View.GONE); youtubeFallback(contentBlock.getVideoUrl()); } }); } mYouTubeThumbnailView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendResetYoutubeBroadcast(); LocalBroadcastManager.getInstance(mContext).registerReceiver(mResetYoutubeBroadCastReciever, new IntentFilter(RESET_YOUTUBE)); mVideoPlayImageView.setVisibility(View.GONE); final FrameLayout frame = new FrameLayout(mContext); frame.setId(R.id.youtube_fragment_id); FrameLayout.LayoutParams layoutParams = layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); frame.setLayoutParams(layoutParams); mFramelayout.addView(frame); final YouTubePlayerSupportFragment youTubePlayerSupportFragment = YouTubePlayerSupportFragment .newInstance(); mFragment.getChildFragmentManager().beginTransaction() .add(frame.getId(), youTubePlayerSupportFragment).commit(); youTubePlayerSupportFragment.initialize(mYoutubeApiKey, new YouTubePlayer.OnInitializedListener() { @Override public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer youTubePlayer, boolean b) { youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT); youTubePlayer.loadVideo(youtubeVideoId); mProgressBar.setVisibility(View.GONE); youTubePlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() { @Override public void onFullscreen(boolean enterFullscreen) { if (enterFullscreen) { Intent intent = YouTubeStandalonePlayer.createVideoIntent( mFragment.getActivity(), mYoutubeApiKey, youtubeVideoId, youTubePlayer.getCurrentTimeMillis(), true, false); mFragment.getActivity().startActivity(intent); } } }); } @Override public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { mProgressBar.setVisibility(View.GONE); youtubeFallback(contentBlock.getVideoUrl()); Log.e("tag", youTubeInitializationResult.toString()); } }); } }); }
From source file:id.nci.stm_9.ExpandableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses can override to * replace with their own layout. If doing so, the returned view hierarchy <em>must</em> have a * ListView whose id is {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when the * list is empty.// w ww. ja v a 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 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)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:org.dvbviewer.controller.ui.base.BaseListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * /*from w w w . j a v a 2s.c o m*/ * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. * * @param inflater the inflater * @param container the container * @param savedInstanceState the saved instance state * @return the view * @author RayBa * @date 07.04.2013 */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); if (layoutRessource > 0) { View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null); return v; } else { 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.progressBarStyle); 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(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); 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:de.grobox.liberario.TripsActivity.java
private void addTrips(final TableLayout main, List<Trip> trip_list, boolean append) { if (trip_list != null) { // reverse order of trips if they should be prepended if (!append) { ArrayList<Trip> tempResults = new ArrayList<Trip>(trip_list); Collections.reverse(tempResults); trip_list = tempResults;//ww w . j av a 2 s .c om } for (final Trip trip : trip_list) { final LinearLayout trip_layout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.trip, null); TableRow row = (TableRow) trip_layout.findViewById(R.id.tripTableRow); // Locations TextView fromView = (TextView) row.findViewById(R.id.fromView); fromView.setText(trip.from.uniqueShortName()); TextView toView = ((TextView) row.findViewById(R.id.toView)); toView.setText(trip.to.uniqueShortName()); // Departure Time and Delay TextView departureTimeView = (TextView) row.findViewById(R.id.departureTimeView); TextView departureDelayView = (TextView) row.findViewById(R.id.departureDelayView); if (trip.getFirstPublicLeg() != null) { LiberarioUtils.setDepartureTimes(this, departureTimeView, departureDelayView, trip.getFirstPublicLeg().departureStop); } else { departureTimeView.setText(DateUtils.getTime(this, trip.getFirstDepartureTime())); } // Arrival Time and Delay TextView arrivalTimeView = (TextView) row.findViewById(R.id.arrivalTimeView); TextView arrivalDelayView = (TextView) row.findViewById(R.id.arrivalDelayView); if (trip.getLastPublicLeg() != null) { LiberarioUtils.setArrivalTimes(this, arrivalTimeView, arrivalDelayView, trip.getLastPublicLeg().arrivalStop); } else { arrivalTimeView.setText(DateUtils.getTime(this, trip.getLastArrivalTime())); } // Duration TextView durationView = (TextView) trip_layout.findViewById(R.id.durationView); durationView .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime())); // Transports FlowLayout lineLayout = (FlowLayout) trip_layout.findViewById(R.id.lineLayout); // for each leg for (final Leg leg : trip.legs) { if (leg instanceof Trip.Public) { LiberarioUtils.addLineBox(this, lineLayout, ((Public) leg).line); } else if (leg instanceof Trip.Individual) { LiberarioUtils.addWalkingBox(this, lineLayout); } } // remember trip in view for onClick event trip_layout.setTag(trip); // make trip details fold out and in on click trip_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View v = main.getChildAt(main.indexOfChild(view) + 1); if (v != null) { if (v.getVisibility() == View.GONE) { v.setVisibility(View.VISIBLE); } else if (v.getVisibility() == View.VISIBLE) { v.setVisibility(View.GONE); } } } }); trip_layout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { selectTrip(view, trip_layout); return true; } }); // show more button for trip details final ImageView showMoreView = (ImageView) trip_layout.findViewById(R.id.showMoreView); showMoreView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { selectTrip(view, trip_layout); } }); // Create container for trip details fragment FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.setId(mContainerId); fragmentContainer.setVisibility(View.GONE); // Create a new Fragment to be placed in the activity layout TripDetailFragment tripDetailFragment = new TripDetailFragment(); // In case this activity was started with special instructions from an // Intent, pass the Intent's extras to the fragment as arguments Bundle bundle = new Bundle(); bundle.putSerializable("de.schildbach.pte.dto.Trip", trip); bundle.putSerializable("de.schildbach.pte.dto.Trip.from", from); bundle.putSerializable("de.schildbach.pte.dto.Trip.to", to); tripDetailFragment.setArguments(bundle); // Add the fragment to the 'fragment_container' FrameLayout getSupportFragmentManager().beginTransaction().add(mContainerId, tripDetailFragment).commit(); mContainerId++; if (append) { trip_layout.addView(LiberarioUtils.getDivider(this)); main.addView(trip_layout); main.addView(fragmentContainer); } else { trip_layout.addView(LiberarioUtils.getDivider(this), 0); main.addView(trip_layout, 0); main.addView(fragmentContainer, 1); } } // end foreach trip } else { // TODO offer option to query again for trips } }
From source file:de.mprengemann.hwr.timetabel.TimetableActivity.java
@Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); Appirater.appLaunched(this, new View.OnClickListener() { @Override// w w w. j av a 2 s .co m public void onClick(View v) { startActivity(new Intent(TimetableActivity.this, DonationsActivity.class)); } }); BugSenseHandler.initAndStartSession(this, getString(R.string.bugtracking_api)); FrameLayout frame = new FrameLayout(this); frame.setId(CONTENT_VIEW_ID); setContentView(frame, new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT)); subjectFragment = SubjectListFragment.newInstance(); subjectFragment.setOnItemClickListener(new OnItemClickListener() { @Override public void onClick(View v, long subject_id, long event_id) { Intent i = new Intent(TimetableActivity.this, SubjectDetailActivity_.class); i.putExtra(SubjectDetailFragment.EXTRA_EVENT_ID, event_id); i.putExtra(SubjectDetailFragment.EXTRA_SUBJECT_ID, subject_id); TimetableActivity.this.startActivity(i); } @Override public boolean onLongClick(View v, long subject_id, long event_id) { return true; } }); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(CONTENT_VIEW_ID, subjectFragment).commit(); setSupportProgressBarIndeterminateVisibility(false); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); initListNavigation(); try { startUpCheck(); } catch (Exception e) { Log.e(TAG, "Can't show Dialog on startup check! " + e.getMessage()); BugSenseHandler.sendException(e); } }
From source file:androidx.navigation.fragment.NavHostFragment.java
@Nullable @Override//w ww. j av a 2s .com public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { FrameLayout frameLayout = new FrameLayout(inflater.getContext()); // When added via XML, this has no effect (since this FrameLayout is given the ID // automatically), but this ensures that the View exists as part of this Fragment's View // hierarchy in cases where the NavHostFragment is added programmatically as is required // for child fragment transactions frameLayout.setId(getId()); return frameLayout; }
From source file:foam.starwisp.DrawableMap.java
public void init(int id, ViewGroup parent, StarwispActivity c, StarwispBuilder b, String mode) { m_parent = parent;//from w ww. j a v a 2 s. c om map_ready = false; draw_mode = false; button_mode = false; m_Context = c; m_Builder = b; map_mode = mode; ID = id; current_polygon = new Vector<LatLng>(); polygons = new Vector<Polygon>(); centre_lat = 49.198935; centre_lon = 2.988281; centre_zoom = 4; draw_indicator = false; indicator_lat = 0; indicator_lon = 0; FrameLayout outer_map = new FrameLayout(c); outer_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); FrameLayout map_container = new FrameLayout(c); map_container.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); map_container.setId(ID); SupportMapFragment mapfrag = SupportMapFragment.newInstance(); FragmentTransaction fragmentTransaction = c.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(ID, mapfrag); fragmentTransaction.commit(); outer_map.addView(map_container); fram_map = new FrameLayout(c); fram_map.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); outer_map.addView(fram_map); if (map_mode.equals("edit")) { map_cont = new LinearLayout(c); map_cont.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); lp.gravity = Gravity.CENTER; map_cont.setLayoutParams(lp); scribble_button = new Button(c); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER; scribble_button.setLayoutParams(lp); scribble_button.setTextSize(20); scribble_button.setTypeface(((StarwispActivity) c).m_Typeface); scribble_button.setText("Draw field"); map_cont.addView(scribble_button); m_instructions = new TextView(c); m_instructions.setLayoutParams(lp); m_instructions.setTextSize(20); m_instructions.setTypeface(m_Context.m_Typeface); m_instructions.setTextColor(Color.WHITE); // arg i18n map_cont.addView(m_instructions); fram_map.addView(map_cont); } else { //button_mode=true; } parent.addView(outer_map); mapfrag.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { map = googleMap; map.setMapType(GoogleMap.MAP_TYPE_SATELLITE); map.setMyLocationEnabled(true); map.getUiSettings().setZoomControlsEnabled(true); SetupStuff(); DrawMap(); Log.i("starwisp", "map made"); Log.i("starwisp", "updating map centre to " + centre_lat + " " + centre_lon); //CameraUpdate center_map=CameraUpdateFactory.newLatLng(new LatLng(centre_lat,centre_lon)); //CameraUpdate zoom_map=CameraUpdateFactory.zoomTo(centre_zoom); //map.moveCamera(center_map); //map.animateCamera(zoom_map); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(centre_lat, centre_lon)).zoom(centre_zoom).build(); map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); map_ready = true; } }); }
From source file:gr.plushost.prototypeapp.widgets.LabelView.java
private boolean replaceLayout(View target) { if (getParent() != null || target == null || target.getParent() == null || _labelViewContainerID != -1) { return false; }/*from w w w . j ava 2s . com*/ ViewGroup parentContainer = (ViewGroup) target.getParent(); if (target.getParent() instanceof FrameLayout) { ((FrameLayout) target.getParent()).addView(this); } else if (target.getParent() instanceof ViewGroup) { int groupIndex = parentContainer.indexOfChild(target); _labelViewContainerID = generateViewId(); // relativeLayout need copy rule if (target.getParent() instanceof RelativeLayout) { for (int i = 0; i < parentContainer.getChildCount(); i++) { if (i == groupIndex) { continue; } View view = parentContainer.getChildAt(i); RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams(); for (int j = 0; j < para.getRules().length; j++) { if (para.getRules()[j] == target.getId()) { para.getRules()[j] = _labelViewContainerID; } } view.setLayoutParams(para); } } parentContainer.removeView(target); // new dummy layout FrameLayout labelViewContainer = new FrameLayout(getContext()); ViewGroup.LayoutParams targetLayoutParam = target.getLayoutParams(); labelViewContainer.setLayoutParams(targetLayoutParam); target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // add target and label in dummy layout labelViewContainer.addView(target); labelViewContainer.addView(this); labelViewContainer.setId(_labelViewContainerID); // add dummy layout in parent container parentContainer.addView(labelViewContainer, groupIndex, targetLayoutParam); } return true; }
From source file:de.elanev.studip.android.app.frontend.courses.CourseDocumentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final FrameLayout wrapperLayout = new FrameLayout(getActivity()); wrapperLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); wrapperLayout.setId(R.id.document_list_wrapper); return wrapperLayout; }
From source file:cn.jasonlv.siri.activity.MainActivity.java
public void onNavigationDrawerItemSelected(int position) { if (position == 1) { Intent intent = new Intent(this, TodoActivity.class); startActivity(intent);//from w w w.j av a 2s . c o m } if (position == 0) { FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.setId(fragmentConatainerId); container.addView(fragmentContainer); getFragmentManager().beginTransaction() .replace(fragmentConatainerId, TodoEditorFragment.newInstance("a", "a")).commit(); fragmentConatainerId++; } if (position == 2) { Intent intent = new Intent(this, Setting.class); startActivity(intent); } if (position == 3) { Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); } }