List of usage examples for android.widget FrameLayout addView
public void addView(View child)
Adds a child view.
From source file:android.support.design.widget.BottomSheetDialog.java
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) { final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(), R.layout.design_bottom_sheet_dialog, null); if (layoutResId != 0 && view == null) { view = getLayoutInflater().inflate(layoutResId, coordinator, false); }// www. j ava 2 s .c o m FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet); mBehavior = BottomSheetBehavior.from(bottomSheet); mBehavior.setBottomSheetCallback(mBottomSheetCallback); mBehavior.setHideable(mCancelable); if (params == null) { bottomSheet.addView(view); } else { bottomSheet.addView(view, params); } // We treat the CoordinatorLayout as outside the dialog though it is technically inside coordinator.findViewById(R.id.touch_outside).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCancelable && isShowing() && shouldWindowCloseOnTouchOutside()) { cancel(); } } }); // Handle accessibility events ViewCompat.setAccessibilityDelegate(bottomSheet, new AccessibilityDelegateCompat() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) { super.onInitializeAccessibilityNodeInfo(host, info); if (mCancelable) { info.addAction(AccessibilityNodeInfoCompat.ACTION_DISMISS); info.setDismissable(true); } else { info.setDismissable(false); } } @Override public boolean performAccessibilityAction(View host, int action, Bundle args) { if (action == AccessibilityNodeInfoCompat.ACTION_DISMISS && mCancelable) { cancel(); return true; } return super.performAccessibilityAction(host, action, args); } }); return coordinator; }
From source file:com.ichi2.anki.Reviewer.java
private void createWhiteboard() { mWhiteboard = new Whiteboard(this, mNightMode, mBlackWhiteboard); FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT); mWhiteboard.setLayoutParams(lp2);//from w w w . j a va2 s. c o m FrameLayout fl = (FrameLayout) findViewById(R.id.whiteboard); fl.addView(mWhiteboard); mWhiteboard.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (mShowWhiteboard) { return false; } return getGestureDetector().onTouchEvent(event); } }); mWhiteboard.setEnabled(true); }
From source file:com.dpcsoftware.mn.CategoryStats.java
public void renderGraph() { SQLiteDatabase db = DatabaseHelper.quickDb(this, 0); if (date == null) date = Calendar.getInstance().getTime(); String queryModifier = ""; if (isByMonth) queryModifier = " AND strftime('%Y-%m'," + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_DATAT + ") = '" + app.dateToDb("yyyy-MM", date) + "'"; Cursor c = db.rawQuery("SELECT " + Db.Table2.TABLE_NAME + "." + Db.Table2._ID + "," + Db.Table2.TABLE_NAME + "." + Db.Table2.COLUMN_NCAT + "," + Db.Table2.TABLE_NAME + "." + Db.Table2.COLUMN_CORCAT + "," + "SUM(" + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_VALORT + ")" + " FROM " + Db.Table1.TABLE_NAME + "," + Db.Table2.TABLE_NAME + " WHERE " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDCAT + " = " + Db.Table2.TABLE_NAME + "." + Db.Table2._ID + " AND " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDGRUPO + " = " + app.activeGroupId + queryModifier + " GROUP BY " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDCAT + " ORDER BY " + Db.Table2.COLUMN_NCAT, null); float[] values = new float[c.getCount()]; int[] colors = new int[c.getCount()]; float total = 0; while (c.moveToNext()) { values[c.getPosition()] = c.getFloat(3); colors[c.getPosition()] = c.getInt(2); total += c.getFloat(3);/* w w w .ja va 2 s. c o m*/ } BarChart v = new BarChart(this, values, colors); v.setPadding(10, 10, 10, 10); FrameLayout graphLayout = ((FrameLayout) findViewById(R.id.FrameLayout1)); if (graphLayout.getChildCount() == 1) graphLayout.removeViewAt(0); graphLayout.addView(v); ListView lv = ((ListView) findViewById(R.id.listView1)); ((TextView) footer.findViewById(R.id.textView2)).setText(app.printMoney(total)); int days = 1; if (!isByMonth) { SimpleDateFormat dateF = new SimpleDateFormat("yyyy-MM-dd"); dateF.setTimeZone(TimeZone.getDefault()); Cursor cTemp = db.rawQuery("SELECT " + Db.Table1.COLUMN_DATAT + " FROM " + Db.Table1.TABLE_NAME + " WHERE " + Db.Table1.COLUMN_IDGRUPO + " = " + app.activeGroupId + " ORDER BY " + Db.Table1.COLUMN_DATAT + " DESC", null); try { cTemp.moveToFirst(); Date date2 = dateF.parse(cTemp.getString(0)); cTemp.moveToLast(); Date date1 = dateF.parse(cTemp.getString(0)); days = (int) Math.ceil((date2.getTime() - date1.getTime()) / (1000.0 * 24 * 60 * 60)) + 1; App.Log("" + days); } catch (Exception e) { e.printStackTrace(); } } else { Calendar cal = Calendar.getInstance(); cal.setTime(date); Calendar now = Calendar.getInstance(); if (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH) && cal.get(Calendar.YEAR) == now.get(Calendar.YEAR)) days = now.get(Calendar.DAY_OF_MONTH); else days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); } ((TextView) footer2.findViewById(R.id.textView2)).setText(app.printMoney(total / days)); ((TextView) findViewById(R.id.textViewMonth)).setText(app.dateToUser("MMMM / yyyy", date)); if (adapter == null) { adapter = new CategoryStatsAdapter(this, c, total); lv.setAdapter(adapter); } else { adapter.changeCursor(c, total); adapter.notifyDataSetChanged(); } }
From source file:com.grarak.kerneladiutor.activities.SecurityActivity.java
private void loadFingerprint() { try {/* w ww . j av a 2 s . c om*/ KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); mCipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); keyStore.load(null); keyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT) .setBlockModes(KeyProperties.BLOCK_MODE_CBC).setUserAuthenticationRequired(true) .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7).build()); keyGenerator.generateKey(); SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null); mCipher.init(Cipher.ENCRYPT_MODE, key); } catch (KeyStoreException | NoSuchProviderException | NoSuchAlgorithmException | NoSuchPaddingException | UnrecoverableKeyException | InvalidKeyException | CertificateException | InvalidAlgorithmParameterException | IOException e) { return; } mCryptoObject = new FingerprintManagerCompat.CryptoObject(mCipher); FrameLayout fingerprintParent = (FrameLayout) findViewById(R.id.fingerprint_parent); final SwirlView swirlView = new SwirlView(new ContextThemeWrapper(this, R.style.Swirl)); swirlView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); fingerprintParent.addView(swirlView); fingerprintParent.setVisibility(View.VISIBLE); mFingerprintUiHelper = new FingerprintUiHelper.FingerprintUiHelperBuilder(mFingerprintManagerCompat) .build(swirlView, new FingerprintUiHelper.Callback() { @Override public void onAuthenticated() { try { mCipher.doFinal(SECRET_MESSAGE.getBytes()); mPasswordWrong.setVisibility(View.GONE); setResult(1); finish(); } catch (IllegalBlockSizeException | BadPaddingException e) { e.printStackTrace(); swirlView.setState(SwirlView.State.ERROR); } } @Override public void onError() { } }); mFingerprintUiHelper.startListening(mCryptoObject); }
From source file:org.jsharkey.oilcan.BrowserActivity.java
public void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.act_browse); scriptdb = new ScriptDatabase(this); scriptdb.onUpgrade(scriptdb.getWritableDatabase(), -10, 10); webview = (WebView) findViewById(R.id.browse_webview); WebSettings settings = webview.getSettings(); settings.setSavePassword(false);/* ww w. j ava2 s . c o m*/ settings.setSaveFormData(false); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); FrameLayout zoomholder = (FrameLayout) this.findViewById(R.id.browse_zoom); zoomholder.addView(webview.getZoomControls()); webview.getZoomControls().setVisibility(View.GONE); webview.setWebViewClient(new OilCanClient()); webview.setWebChromeClient(new OilCanChrome()); webview.addJavascriptInterface(new IntentHelper(), "intentHelper"); // load the last-viewed page into browser String url = "http://m.half.com/"; if (icicle != null && icicle.containsKey(LAST_VIEWED)) url = icicle.getString(LAST_VIEWED); // or watch for incoming requested urls if (getIntent().getExtras() != null && getIntent().getExtras().containsKey(SearchManager.QUERY)) url = getIntent().getStringExtra(SearchManager.QUERY); webview.loadUrl(url); }
From source file:HeaderGridView.java
/** * Add a fixed view to appear at the top of the grid. If addHeaderView is * called more than once, the views will appear in the order they were * added. Views added using this call can take focus if they want. * <p>//from w w w.j av a2s .c o m * NOTE: Call this before calling setAdapter. This is so HeaderGridView can wrap * the supplied cursor with one that will also account for header views. * * @param v The view to add. * @param data Data to associate with this view * @param isSelectable whether the item is selectable */ public void addHeaderView(View v, Object data, boolean isSelectable) { ListAdapter adapter = getAdapter(); if (adapter != null && !(adapter instanceof HeaderViewGridAdapter)) { throw new IllegalStateException( "Cannot add header view to grid -- setAdapter has already been called."); } FixedViewInfo info = new FixedViewInfo(); FrameLayout fl = new FullWidthFixedViewLayout(getContext()); fl.addView(v); info.view = v; info.viewContainer = fl; info.data = data; info.isSelectable = isSelectable; mHeaderViewInfos.add(info); // in the case of re-adding a header view, or adding one later on, // we need to notify the observer if (adapter != null) { ((HeaderViewGridAdapter) adapter).notifyDataSetChanged(); } }
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 w w. j a va 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.example.fazazi.muslimprayer.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*w w w. j av a2 s .co m*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); v.setText("Page " + (position + 1)); fl.addView(v); return fl; }
From source file:com.example.mac.myapplication.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w ww. j a va 2 s . c o m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.github.javiersantos.piracychecker.activities.LicenseActivity.java
private void setActivityData() { FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mainContainer); LayoutInflater factory = LayoutInflater.from(this); View inflateView;// w ww . j a v a 2 s . c o m if (layoutXML == -1) { inflateView = factory.inflate(R.layout.activity_license_default, null); TextView activityDescription = (TextView) inflateView.findViewById(R.id.piracy_checker_description); activityDescription.setText(description); } else inflateView = factory.inflate(layoutXML, null); frameLayout.addView(inflateView); }