List of usage examples for android.widget FrameLayout addView
public void addView(View child)
Adds a child view.
From source file:com.vuze.android.remote.AndroidUtilsUI.java
public static AlertDialog.Builder createTextBoxDialog(Context context, int newtag_title, int newtag_hint, final OnTextBoxDialogClick onClickListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); FrameLayout container = new FrameLayout(context); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; container.setMinimumHeight(AndroidUtilsUI.dpToPx(100)); int padding = AndroidUtilsUI.dpToPx(20); params.leftMargin = padding;//from w ww . jav a 2 s . c o m params.rightMargin = padding; final MaterialEditText textView = AndroidUtilsUI.createFancyTextView(context); textView.setHint(newtag_hint); textView.setFloatingLabelText(context.getResources().getString(newtag_hint)); textView.setSingleLine(); textView.setLayoutParams(params); container.addView(textView); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { builder.setInverseBackgroundForced(true); } builder.setView(container); builder.setTitle(newtag_title); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onClickListener.onClick(dialog, which, textView); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); return builder; }
From source file:com.dimasdanz.kendalipintu.BarcodeOpenDoorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_barcode_open_door); autoFocusHandler = new Handler(); mCamera = getCameraInstance();//from w ww .j a v a 2s.c om scanner = new ImageScanner(); scanner.setConfig(0, Config.X_DENSITY, 3); scanner.setConfig(0, Config.Y_DENSITY, 3); mPreview = new BarcodePreview(this, mCamera, previewCb, autoFocusCB); FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview); preview.addView(mPreview); }
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 ww w . ja v 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++;/* ww w . j a va 2 s . c om*/ } } 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.bringcommunications.etherpay.ScanActivity.java
private void do_scan_guts() { mCamera = getCameraInstance();// ww w .j av a 2 s . c om mPreview = new CameraPreview(this, mCamera, this, autoFocusCB); FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview); preview.addView(mPreview); mCamera.setPreviewCallback(this); mCamera.startPreview(); previewing = true; try { mCamera.autoFocus(autoFocusCB); } catch (Exception e) { System.out.println("autofocus failed: " + e.toString()); } }
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 . ja v a 2s . c o 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:com.osama.cgpacalculator.MainActivity.java
@SuppressLint("InflateParams") private void showAboutDialog() { final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f); animation.setDuration(800);//ww w .ja v a 2s.c o m Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.about_dialog); final FrameLayout frame = ((FrameLayout) dialog.findViewById(R.id.about_content_layout)); frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); dialog.findViewById(R.id.credit_dialog_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { frame.removeAllViews(); isShowingLi = false; if (!isShowingCr) { frame.addView(getLayoutInflater().inflate(R.layout.credits_layout, null)); isShowingCr = true; frame.setAnimation(animation); } else { frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); isShowingCr = false; frame.setAnimation(animation); } frame.animate(); } }); dialog.findViewById(R.id.license_dialog_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { frame.removeAllViews(); isShowingCr = false; if (!isShowingLi) { frame.addView(getLayoutInflater().inflate(R.layout.license_layout, null)); isShowingLi = true; frame.setAnimation(animation); } else { frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); isShowingLi = false; frame.setAnimation(animation); } frame.animate(); } }); dialog.show(); }
From source file:de.escoand.readdaily.CalendarDialogFragment.java
@NonNull @Override/* ww w.j a v a2 s.com*/ public Dialog onCreateDialog(final Bundle savedInstanceState) { FrameLayout v = new FrameLayout(getContext()); progress = new ProgressBar(new ContextThemeWrapper(getContext(), R.style.Progress_Circular)); cal = new MaterialCalendarView(getContext()); v.addView(progress); v.addView(cal); progress.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); cal.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); cal.addDecorator(new AvailableDecorator()); cal.addDecorator(new ReadDecorator()); cal.setOnDateChangedListener(this); new DataLoader().execute(); return new AlertDialog.Builder(getContext()).setTitle(R.string.navigation_calendar).setView(v) .setNegativeButton(R.string.button_cancel, null).create(); }
From source file:com.just.agentweb.VideoImpl.java
@Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity;/*from w w w. j ava 2 s. com*/ if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return; } mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair = null; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (mMoiveView != null) { callback.onCustomViewHidden(); return; } if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (mMoiveParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); mMoiveParentView = new FrameLayout(mActivity); mMoiveParentView.setBackgroundColor(Color.BLACK); mDecorView.addView(mMoiveParentView); } this.mCallback = callback; mMoiveParentView.addView(this.mMoiveView = view); mMoiveParentView.setVisibility(View.VISIBLE); }
From source file:ul.ceids.prueba.pager.GDFragmentActivity.java
public void setActionBarContentView(View view) { final FrameLayout contentView = getContentView(); contentView.removeAllViews();// www . ja v a 2s. co m contentView.addView(view); }