List of usage examples for android.widget FrameLayout removeAllViews
public void removeAllViews()
From source file:cn.pjt.rxjava.camera.CameraPreviewFragment.java
private void initCamera() { mCamera = getCameraInstance(CAMERA_ID); Camera.CameraInfo cameraInfo = null; if (mCamera != null) { // Get camera info only if the camera is available cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(CAMERA_ID, cameraInfo); }/*from w ww. j a v a 2 s. co m*/ // Get the rotation of the screen to adjust the preview image accordingly. final int displayRotation = getActivity().getWindowManager().getDefaultDisplay().getRotation(); if (getView() == null) { return; } FrameLayout preview = (FrameLayout) getView().findViewById(R.id.camera_preview); preview.removeAllViews(); if (mPreview == null) { // Create the Preview view and set it as the content of this Activity. mPreview = new CameraPreview(getActivity(), mCamera, cameraInfo, displayRotation); } else { mPreview.setCamera(mCamera, cameraInfo, displayRotation); } preview.addView(mPreview); }
From source file:com.nubisa.jxcore.MainActivity.java
@Override protected void onDestroy() { super.onDestroy(); Log.w("jxcore-MainActivity", "destroy"); FrameLayout layout = (FrameLayout) AppManager.currentActivity.findViewById(R.id.container); layout.removeAllViews(); web.destroy();/*from ww w.j av a 2 s . c o m*/ web = null; instance_alive = false; }
From source file:oly.netpowerctrl.main.MainActivity.java
private void assignContentView() { setContentView(R.layout.activity_main); boolean has_two_panes = getResources().getBoolean(R.bool.has_two_panes); LayoutInflater l = LayoutInflater.from(this); FragmentUtils.unloadFragment(this, "group"); FrameLayout layout = (FrameLayout) findViewById(R.id.content); layout.removeAllViews(); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); View v = l.inflate(!has_two_panes ? R.layout.content_frame_with_sliding_group_list : R.layout.content_frame_with_group_list, null); layout.addView(v, lp);// w w w . j a v a 2 s. c o m FragmentUtils.loadFragment(this, GroupListFragment.class.getName(), R.id.group_list_fragment, "group"); FragmentUtils.changeToFragment(this, ExecutablesFragment.class.getName(), "outlets", null); if (!has_two_panes) { panes = (SlidingPaneLayout) findViewById(R.id.drawerLayout); Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 240, r.getDisplayMetrics()); panes.setParallaxDistance((int) px / 2); panes.setCoveredFadeColor(0); panes.setSliderFadeColor(0); panes.setShadowResourceLeft(R.drawable.drawer_shadow_left); panes.setShadowResourceRight(R.drawable.drawer_shadow); panes.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { } @Override public void onPanelOpened(View panel) { } @Override public void onPanelClosed(View panel) { } }); //if (panes.isSlideable()) panes.openPane(); } if (SharedPrefs.getInstance().isBackground()) { Drawable d = LoadStoreIconData.loadBackgroundBitmap(); findViewById(android.R.id.content).setBackground(d); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); setSupportActionBar(toolbar); }
From source file:com.google.android.gcm.demo.ui.GroupsFragment.java
@Override public void refresh() { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> senders = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < senders.size(); i++) { Sender sender = senders.valueAt(i); if (sender.groups.size() > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderText = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderText.setText(getString(R.string.groups_sender_id, sender.senderId)); sendersList.addView(senderRow); for (DeviceGroup deviceGroup : sender.groups.values()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.group_grey600); label.setText(deviceGroup.notificationKeyName); label.setBackgroundResource(selectableBackgroundResource); label.setTag(R.id.tag_action, ACTION_OPEN_GROUP); label.setTag(R.id.tag_senderid, sender.senderId); label.setTag(R.id.tag_group, deviceGroup.notificationKeyName); label.setOnClickListener(this); button.setText(R.string.groups_delete); button.setTag(R.id.tag_action, ACTION_DELETE_GROUP); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_group, deviceGroup.notificationKeyName); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); }/*from w w w . j av a 2 s . c o m*/ } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.groups_no_groups_available)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.groups_list_wrapper); topicsView.removeAllViews(); topicsView.addView(sendersList); }
From source file:com.google.android.gcm.demo.ui.TopicsFragment.java
@Override public void refresh() { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < addressBook.size(); i++) { Sender sender = addressBook.valueAt(i); // Check if at least a topic is subscribed for this sender int subscribedTopics = 0; for (Boolean subscribed : sender.topics.values()) { if (subscribed) { subscribedTopics++;//from www . j a va 2 s. com } } if (subscribedTopics > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId)); sendersList.addView(senderRow); for (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) { if (topic.getValue()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.bigtop_updates_grey600); label.setText(topic.getKey()); button.setText(R.string.topics_unsubscribe); button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_topic, topic.getKey()); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); } } } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.topics_no_topic_subscribed)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper); topicsView.removeAllViews(); topicsView.addView(sendersList); }
From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java
@Override public void refresh() { new AsyncTask<Void, Void, Void>() { @Override/*from w w w . j av a 2 s. co m*/ protected Void doInBackground(Void... params) { final String instanceId = mInstanceIdHelper.getInstanceId(); final String creationTime = DateFormat.getDateTimeInstance() .format(new Date(mInstanceIdHelper.getCreationTime())); final Activity activity = getActivity(); if (activity != null) { Handler handler = new Handler(activity.getMainLooper()); handler.post(new Runnable() { public void run() { setValue(activity.findViewById(R.id.iid_instance_id), instanceId); setValue(activity.findViewById(R.id.iid_creation_time), creationTime); } }); } return null; } }.execute(); float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < addressBook.size(); i++) { Sender sender = addressBook.valueAt(i); if (sender.appTokens.size() > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId)); sendersList.addView(senderRow); for (Token token : sender.appTokens.values()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.smartphone_grey600); label.setText(token.scope + " - " + AbstractFragment.truncateToMediumString(token.token)); button.setText(R.string.iid_delete_token); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_scope, token.scope); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); } } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.iid_no_tokens)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper); tokensView.removeAllViews(); tokensView.addView(sendersList); }
From source file:ul.ceids.prueba.pager.GDFragmentActivity.java
public void setActionBarContentView(int resID) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); LayoutInflater.from(this).inflate(resID, contentView); }
From source file:ul.ceids.prueba.pager.GDFragmentActivity.java
public void setActionBarContentView(View view, LayoutParams params) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); contentView.addView(view, params);// w ww . jav a 2 s .co m }
From source file:ul.ceids.prueba.pager.GDFragmentActivity.java
public void setActionBarContentView(View view) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); contentView.addView(view);/*from w w w . ja v a2 s . c om*/ }
From source file:info.tellmetime.DaydreamService.java
private void inflateMinutesIndicators() { FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews(); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); }//from ww w . j ava 2 s. c o m minutesLayout.setLayoutParams(layoutParams); Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } }