List of usage examples for android.widget RelativeLayout addView
public void addView(View child)
Adds a child view.
From source file:com.jaspervanriet.huntingthatproduct.Views.FeedContextMenuManager.java
private void showContextMenuFromView(final View openingView, int feedItem, FeedContextMenu.OnFeedContextMenuItemClickListener listener, boolean isMainActivity) { if (!isContextMenuShowing) { isContextMenuShowing = true;/*from w w w.j av a2s. c o m*/ contextMenuView = new FeedContextMenu(openingView.getContext()); contextMenuView.bindToItem(feedItem); contextMenuView.addOnAttachStateChangeListener(this); contextMenuView.setOnFeedMenuItemClickListener(listener); ViewGroup viewGroup = (ViewGroup) openingView.getRootView().findViewById(android.R.id.content); RelativeLayout relativeLayout; if (isMainActivity) { DrawerLayout drawerLayout = (DrawerLayout) viewGroup.getChildAt(0); relativeLayout = (RelativeLayout) drawerLayout.getChildAt(0); } else { relativeLayout = (RelativeLayout) viewGroup.getChildAt(0); } relativeLayout.addView(contextMenuView); contextMenuView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { contextMenuView.getViewTreeObserver().removeOnPreDrawListener(this); setupContextMenuInitialPosition(openingView); performShowAnimation(); return false; } }); } }
From source file:edu.rowan.app.fragments.HomescreenFragment.java
/** * Construct the view for this fragment. * The core layout of this fragment is a CarouselView and grid of available buttons *///from w ww . j av a 2 s. com @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // hide actionbar loading indicator TODO: move this elsewhere activity.showLoading(false); View view = inflater.inflate(R.layout.activity_main, container, false); RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.mainLayout); layout.setPadding(0, 20, 0, 0); CarouselView rowanFeatures = new CarouselView(inflater.getContext()); // set view Id so that relativeLayout can position. Without an Id relativeLayout doesn't work rowanFeatures.setId(2342343); layout.addView(rowanFeatures); setTouchListener(rowanFeatures); GridView grid = new GridView(inflater.getContext()); grid.setOnItemClickListener(this); grid.setNumColumns(3); grid.setVerticalSpacing(20); grid.setAdapter(new RowanAdapter()); RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); gridParams.addRule(RelativeLayout.BELOW, rowanFeatures.getId()); gridParams.topMargin = 20; layout.addView(grid, gridParams); return view; }
From source file:com.support.android.designlibdemo.MatchedPetsDetailActivity.java
/**********************************************************************************************/ private AlertDialog createReportDialog(String titulo, String message) { // Instanciamos un nuevo AlertDialog Builder y le asociamos titulo y mensaje AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(titulo); alertDialogBuilder.setMessage(message); RelativeLayout linearLayout = new RelativeLayout(this); final EditText link = new EditText(this); link.setHint("Causa de la denuncia"); link.setWidth(750);//from www .ja v a2s . c om linearLayout.addView(link); linearLayout.setPadding(70, 0, 0, 0); alertDialogBuilder.setView(linearLayout); link.invalidate(); linearLayout.invalidate(); final String petId = getIntent().getStringExtra("id"); final String reporterId = this.loginUser.getId(); // Creamos un nuevo OnClickListener para el boton OK que realice la conexion DialogInterface.OnClickListener listenerOk = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { reportComplain(petId, reporterId, link.getText().toString()); } }; // Creamos un nuevo OnClickListener para el boton Cancelar DialogInterface.OnClickListener listenerCancelar = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }; // Asignamos los botones positivo y negativo a sus respectivos listeners //OJO: estan al reves para que sea display si - no en vez de no - si alertDialogBuilder.setPositiveButton(R.string.dialogCancel, listenerCancelar); alertDialogBuilder.setNegativeButton(R.string.dialogSend, listenerOk); return alertDialogBuilder.create(); }
From source file:org.secuso.privacyfriendlydicegame.MainActivity.java
public void setDice(int[] results) { RelativeLayout diceContainer = (RelativeLayout) findViewById(R.id.dice_frame); RelativeLayout diceRowTwo = (RelativeLayout) findViewById(R.id.dice_frame_second); for (int i = 0; i < 3; i++) { diceContainer.addView(displayResults(results[i], dice[i])); }//from www.j a v a 2 s.c o m for (int k = 3; k < dice.length; k++) { diceRowTwo.addView(displayResults(results[k], dice[k])); } }
From source file:me.ziccard.secureit.fragment.EmptyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) { mContent = savedInstanceState.getString(CONTENT); }/*from w w w . j av a2 s .c o m*/ TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); RelativeLayout layout = new RelativeLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setGravity(Gravity.CENTER); RelativeLayout alert = new RelativeLayout(getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 20; params.rightMargin = 20; params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_IN_PARENT); alert.setLayoutParams(params); alert.setBackgroundResource(R.drawable.red_back); alert.setPadding(30, 0, 30, 0); alert.addView(text); layout.addView(alert); return layout; }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
/** * Executed when tabhost is created//ww w .j a va 2s. c om */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ----------------- GUI ------------ resources = SetResources(); // ---Load Prefs and Modify resources // accordingly setContentView(R.layout.factivity_tabhost); // ---------- Content view ctx = this; btSetup = new Button(ctx); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); btSetup.setLayoutParams(params); RelativeLayout rl = (RelativeLayout) findViewById(R.id.tbs); rl.addView(btSetup); btSetup.bringToFront(); btSetup.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Fragment_Issue_Details.mfrag_issue_details != null) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(Fragment_Issue_Details.mfrag_issue_details); ft.commit(); getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } mTabHost.getTabWidget().getChildAt(4).findViewWithTag("hbar") .setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_orange)); startActivity(new Intent(ctx, Activity_Setup.class)); } }); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); // --------------------------------------- for (int i = 0; i < NTabs; i++) mTabSpec[i] = mTabHost.newTabSpec("tid" + Integer.toString(i)); mD_Main = getResources().getDrawable(R.drawable.ic_map); mD_List = getResources().getDrawable(R.drawable.ic_list); mD_Report = getResources().getDrawable(R.drawable.ic_plus); mD_Filters = getResources().getDrawable(R.drawable.ic_filter); mD_Setup = getResources().getDrawable(R.drawable.ic_settings); // -------------- Set icons and texts localized per tab ------------- LinearLayout llA = make_Active_Tab(resources.getString(R.string.Map), mD_Main); llA.setClickable(true); LinearLayout llB = make_Inactive_Tab(resources.getString(R.string.List), mD_List); LinearLayout llC = make_Inactive_Tab(resources.getString(R.string.Report), mD_Report); LinearLayout llD = make_Inactive_Tab(resources.getString(R.string.Filter), mD_Filters); LinearLayout llE = make_Inactive_Tab(resources.getString(R.string.Settings), mD_Setup); mTabSpec[0].setIndicator(llA); mTabSpec[1].setIndicator(llB); mTabSpec[2].setIndicator(llC); mTabSpec[3].setIndicator(llD); mTabSpec[4].setIndicator(llE); // Add tabSpec to the TabHost to display mTabHost.addTab(mTabSpec[0], Fragment_Map.class, null); mTabHost.addTab(mTabSpec[1], Fragment_List.class, null); mTabHost.addTab(mTabSpec[2], Fragment_NewIssueA.class, null); mTabHost.addTab(mTabSpec[3], Fragment_Filters.class, null); mTabHost.addTab(mTabSpec[4], null, null); // implemented with a button // overlapped because there // was no fragment for // Preferences in support // lib v4 mTabHost.setOnTabChangedListener(this); mTabHost.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { btSetup.setWidth(mTabHost.getTabWidget().getChildAt(4).getWidth()); btSetup.setHeight(mTabHost.getTabWidget().getChildAt(4).getHeight()); btSetup.bringToFront(); } }); }
From source file:com.normalexception.app.rx8club.fragment.utils.CompressionFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainApplication.setState(AppState.State.UTIL_COMPRESSION, this); RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.content_frame); v = getActivity().getLayoutInflater().inflate(R.layout.view_compression, rl); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);/*from ww w . j av a2 s.c o m*/ params.addRule(RelativeLayout.BELOW, R.id.mainlisttitle); ScrollView sv = new ScrollView(getActivity()); sv.addView(v); sv.setLayoutParams(params); rl.addView(sv); ViewHolder.get(v, R.id.compressionNormalize).setOnClickListener(new CompressionListener()); }
From source file:nz.al4.airclock.AirClockFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.fragment_air_clock, container, false); // clockView = layout; layout.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { updateClock();//from ww w . j a v a 2 s .c o m return true; } }); View tc = setupClock(); View td = setupDate(); View tz = setupTz(); layout.addView(td); layout.addView(tc); layout.addView(tz); updateClock(); return layout; }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void showCopyBubble(final Activity context, final View v, final View t) { try {/* ww w . j a v a2s .c o m*/ if (context == null) return; if (v != null) v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (copy == null) copy = context.getLayoutInflater().inflate(R.layout.copy, null); if (copy == null) return; final RelativeLayout root = (RelativeLayout) context.findViewById(R.id.main_layout); root.removeView(copy); copy.setClickable(true); copy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { if (t != null) { BRClipboardManager.copyToClipboard(context, ((TextView) t).getText().toString()); Log.e(TAG, "clicked copy: " + ((TextView) t).getText().toString()); } hideCopyBubble(context); } catch (Exception e) { e.printStackTrace(); } } }); root.addView(copy); copy.setY(getRelativeTop(v)); copy.setX(MainActivity.screenParametersPoint.x / 2 - 40); } }); if (t != null) t.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View parent = (View) t.getParent(); if (parent != null) parent.performClick(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * ToolBar// w w w. j a va 2s .c o m * @param mainLayout dialog */ private void buildToolbar(LinearLayout mainLayout) { RelativeLayout toolBarLayout = buildToolbarLayout(); RelativeLayout buttonContainerLayout = buildActionButtonContainerLayout(); Button backButton = buildBackButton(); Button forwardButton = buildForwardButton(); Button closeButton = buildCloseButton(); buttonContainerLayout.addView(backButton); buttonContainerLayout.addView(forwardButton); buildEditText(); toolBarLayout.addView(buttonContainerLayout); toolBarLayout.addView(mEditText); toolBarLayout.addView(closeButton); mainLayout.addView(toolBarLayout); }