List of usage examples for android.widget FrameLayout addView
public void addView(View child, int index)
From source file:com.todoroo.astrid.activity.FilterListFragment.java
public static void showCreateShortcutDialog(final Activity activity, final Intent shortcutIntent, final Filter filter) { FrameLayout frameLayout = new FrameLayout(activity); frameLayout.setPadding(10, 0, 10, 0); final EditText editText = new EditText(activity); if (filter.listingTitle == null) filter.listingTitle = ""; //$NON-NLS-1$ editText.setText(filter.listingTitle.replaceAll("\\(\\d+\\)$", "").trim()); //$NON-NLS-1$ //$NON-NLS-2$ frameLayout.addView(editText, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); final Runnable createShortcut = new Runnable() { @Override// w w w. j av a 2 s . c o m public void run() { String label = editText.getText().toString(); createShortcut(activity, filter, shortcutIntent, label); } }; editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL) { createShortcut.run(); return true; } return false; } }); new AlertDialog.Builder(activity).setTitle(R.string.FLA_shortcut_dialog_title) .setMessage(R.string.FLA_shortcut_dialog).setView(frameLayout) .setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createShortcut.run(); } }).setNegativeButton(android.R.string.cancel, null).show().setOwnerActivity(activity); }
From source file:com.androidhiddencamera.HiddenCameraFragment.java
/** * Add camera preview to the root of the activity layout. * * @return {@link CameraPreview} that was added to the view. *//*from w w w. j a v a 2 s. c om*/ private CameraPreview addPreView() { //create fake camera view CameraPreview cameraSourceCameraPreview = new CameraPreview(getActivity(), this); cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); View view = ((ViewGroup) getActivity().getWindow().getDecorView().getRootView()).getChildAt(0); if (view instanceof LinearLayout) { LinearLayout linearLayout = (LinearLayout) view; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1); linearLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) view; RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); relativeLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) view; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1); frameLayout.addView(cameraSourceCameraPreview, params); } else { throw new RuntimeException("Root view of the activity/fragment cannot be frame layout"); } return cameraSourceCameraPreview; }
From source file:com.androidhiddencamera.HiddenCameraActivity.java
/** * Add camera preview to the root of the activity layout. * * @return {@link CameraPreview} that was added to the view. *///w ww .j a va2s.c om private CameraPreview addPreView() { //create fake camera view CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this); cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); View view = ((ViewGroup) getWindow().getDecorView().getRootView()).getChildAt(0); if (view instanceof LinearLayout) { LinearLayout linearLayout = (LinearLayout) view; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1); linearLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) view; RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); relativeLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) view; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1); frameLayout.addView(cameraSourceCameraPreview, params); } else { throw new RuntimeException("Root view of the activity/fragment cannot be frame layout"); } return cameraSourceCameraPreview; }
From source file:org.akvo.flow.ui.fragment.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.map_fragment, container, false); FrameLayout layout = (FrameLayout) v.findViewById(R.id.map_container); layout.addView(mapView, 0); return v;/*from w w w . j a va2 s .c o m*/ }
From source file:com.licenseplate.android.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*ww w. ja va 2 s.c o m*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(getResources().getString(R.string.home)); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, 0); // this disables the animation } }; mDrawerToggle.syncState(); mDrawerLayout.setDrawerListener(mDrawerToggle); // load menu mMenuListView = (ListView) findViewById(R.id.menu_list); mMenuArray = getResources().getStringArray(R.array.menu); mMenuListView.setAdapter(new MenuAdapter(this, mMenuArray)); mMenuListView.setOnItemClickListener(this); mCustomViewPager = (CustomViewPager) findViewById(R.id.vp_pages); mCustomViewPager.setOffscreenPageLimit(3); mPagerAdapter = new HomeAdapter(this); mCustomViewPager.setAdapter(mPagerAdapter); new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { try { Ads.init(HomeActivity.this, APP_ID, SECRET_KEY); return true; } catch (Exception e) { Log.e(TAG, "error", e); return false; } } @Override protected void onPostExecute(Boolean success) { super.onPostExecute(success); Log.e(TAG, "result " + success); if (success) { /** * pre load */ Ads.preLoad(BANNER, Ads.AdFormat.banner); /** * add ad views */ View bannerView = Ads.createBannerView(HomeActivity.this, BANNER); FrameLayout banner = (FrameLayout) findViewById(R.id.banner); banner.addView(bannerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } } }.execute(); }
From source file:org.deviceconnect.android.uiapp.fragment.profile.NetworkServiceDiscoveryProfileFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mLogger.entering(getClass().getName(), "onCreateView", new Object[] { inflater, container, savedInstanceState }); final Context context = getActivity(); FrameLayout lframe = new FrameLayout(context); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list);/* w w w .j a v a 2 s .c o m*/ lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light)); mListView = (ListView) lframe.findViewById(android.R.id.list); mListView.setAdapter(new ArrayAdapter<SmartDevice>(getActivity(), android.R.layout.simple_list_item_1)); (new ServiceDiscoveryTask()).execute(); mLogger.exiting(getClass().getName(), "onCreateView", mListView); return lframe; }
From source file:ul.ceids.prueba.pager.GDFragmentActivity.java
public void setActionBarContentView(View view, LayoutParams params) { final FrameLayout contentView = getContentView(); contentView.removeAllViews();//w w w .ja v a2s . com contentView.addView(view, params); }
From source file:org.solovyev.android.games.game2048.PreferenceListFragment.java
@Override public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final LayoutInflater themeInflater; if (themeResId == NO_THEME) { themeContext = getActivity();/* w w w . j a va2 s . c o m*/ themeInflater = inflater; } else { themeContext = new ContextThemeWrapper(getActivity(), themeResId); themeInflater = LayoutInflater.from(themeContext); } if (layoutResId == NO_LAYOUT) { final FrameLayout frameLayout = new FrameLayout(themeContext); final ListView listView = new ListView(themeContext); listView.setId(android.R.id.list); frameLayout.addView(listView, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); root = frameLayout; } else { root = themeInflater.inflate(layoutResId, null); } final ListView lv = (ListView) root.findViewById(android.R.id.list); prepareListView(lv); onCreateView(themeContext, themeInflater, root, container, savedInstanceState); return root; }
From source file:cz.maresmar.sfm.view.menu.MenuDetailsFragment.java
private void showPickerDialog(@StringRes int title, int min, int max, int value, IntConsumer newValueConsumer) { // Prepare number picker NumberPicker picker = new NumberPicker(getContext()); picker.setMinValue(min);//from ww w . j a va 2 s . co m picker.setMaxValue(max); picker.setValue(value); picker.setWrapSelectorWheel(false); FrameLayout layout = new FrameLayout(getContext()); layout.addView(picker, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // Show alert new AlertDialog.Builder(getContext()).setTitle(title).setMessage(R.string.menu_detail_pick_new_value) .setView(layout).setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { // do something with picker.getValue() newValueConsumer.accept(picker.getValue()); }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:io.github.calvinmikael.anymanga.WebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from ww w.java 2s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_web_view, container, false); mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar); mProgressBar.setVisibility(View.GONE); mWebView = (ObservableWebView) view.findViewById(R.id.webView); mWebView.setScrollViewCallbacks(this); WebSettings settings = mWebView.getSettings(); settings.setLoadsImagesAutomatically(true); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (!mProgressBar.isShown()) { mProgressBar.setVisibility(View.VISIBLE); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (mProgressBar.isShown()) { mProgressBar.setVisibility(View.GONE); } } }); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onShowCustomView(View view, CustomViewCallback callback) { // if a view already exists then immediately terminate the new one if (mCustomView != null) { onHideCustomView(); return; } // Save the current state mCustomView = view; mOriginalSystemUiVisibility = getActivity().getWindow().getDecorView().getSystemUiVisibility(); // Save the custom view callback mCustomViewCallback = callback; // Add the custom view to the view hierarchy FrameLayout decorView = (FrameLayout) getActivity().getWindow().getDecorView(); decorView.addView(mCustomView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mTabStrip = (PagerSlidingTabStrip) getActivity().findViewById(R.id.tabs); mTabStrip.setVisibility(View.GONE); // Go fullscreen if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { getActivity().getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getActivity().getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } } @Override public void onHideCustomView() { // Remove the custom view FrameLayout decorView = (FrameLayout) getActivity().getWindow().getDecorView(); decorView.removeView(mCustomView); mCustomView = null; mTabStrip.setVisibility(View.VISIBLE); // Restore the original form getActivity().getWindow().getDecorView().setSystemUiVisibility(mOriginalSystemUiVisibility); // Call the custom view callback mCustomViewCallback.onCustomViewHidden(); mCustomViewCallback = null; } }); // The back button must be handled within the mWebView for the // mWebView to have back behavior based on the current mPage // if back behavior is not handled with this listener then // back behavior will be entirely dependent on the first mPage mWebView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack() && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { mWebView.goBack(); return true; } return false; } }); if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { if (mPage == 1) { mWebView.loadUrl(getString(R.string.website_kissmanga)); } else if (mPage == 2) { mWebView.loadUrl(getString(R.string.website_mangapark)); } else if (mPage == 3) { mWebView.loadUrl(getString(R.string.website_line_webtoon)); } } return view; }