List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
From source file:com.example.drugsformarinemammals.General_Info_Drug.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.general_info_drug); isStoredInLocal = false;/* w w w .j a va 2 s.com*/ fiveLastScreen = false; helper = new Handler_Sqlite(this); helper.open(); Bundle extras1 = this.getIntent().getExtras(); if (extras1 != null) { infoBundle = extras1.getStringArrayList("generalInfoDrug"); fiveLastScreen = extras1.getBoolean("fiveLastScreen"); if (infoBundle == null) isStoredInLocal = true; if (!isStoredInLocal) { initializeGeneralInfoDrug(); initializeCodesInformation(); initializeCodes(); } else { drug_name = extras1.getString("drugName"); codes = helper.getCodes(drug_name); codesInformation = helper.getCodesInformation(drug_name); } //Title TextView drugTitle = (TextView) findViewById(R.id.drugTitle); drugTitle.setText(drug_name); drugTitle.setTypeface(Typeface.SANS_SERIF); //Description LinearLayout borderDescription = new LinearLayout(this); borderDescription.setOrientation(LinearLayout.VERTICAL); borderDescription .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); borderDescription.setBackgroundResource(R.drawable.layout_border); TextView description = new TextView(this); if (isStoredInLocal) description.setText(helper.getDescription(drug_name)); else description.setText(this.description); description.setTextSize(18); description.setTypeface(Typeface.SANS_SERIF); LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsDescription.leftMargin = 60; paramsDescription.rightMargin = 60; paramsDescription.topMargin = 20; borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription); LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription); layoutDescription.addView(borderDescription, layoutDescription.getChildCount()); //Animals TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals); headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton); cetaceansButton.setText("CETACEANS"); cetaceansButton.setTypeface(Typeface.SANS_SERIF); cetaceansButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Cetaceans"); } }); Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton); pinnipedsButton.setText("PINNIPEDS"); pinnipedsButton.setTypeface(Typeface.SANS_SERIF); pinnipedsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SQLiteDatabase db = helper.open(); ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(drug_name, "Pinnipeds"); if ((families != null && families.size() == 1 && families.get(0).equals("")) || (families != null && families.size() == 0)) showDoseInformation(drug_name, "Pinnipeds"); else showDoseInformationPinnipeds(drug_name, families); } }); Button otherButton = (Button) findViewById(R.id.otherButton); otherButton.setText("OTHER MM"); otherButton.setTypeface(Typeface.SANS_SERIF); otherButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Other MM"); } }); //Codes & therapeutic target & anatomical target TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes); headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); //Action TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical); headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewAnatomical(); createBorderAnatomicalGroup(); TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic); headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewTherapeutic(); createBorderTherapeuticGroup(); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 60; params.rightMargin = 60; params.topMargin = 20; Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner); SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes); adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item); codesSpinner.setAdapter(adapterCodes); codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryCode = parent.getSelectedItem().toString(); int numCodes = codesInformation.size(); layoutAnatomicalGroup.removeView(borderAnatomicalGroup); createBorderAnatomicalGroup(); boolean founded = false; int i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewAnatomical(); anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n"); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); founded = true; } i++; } layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.removeView(borderTherapeuticGroup); createBorderTherapeuticGroup(); founded = false; i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewTherapeutic(); therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n"); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); founded = true; } i++; } layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); } public void onNothingSelected(AdapterView<?> arg0) { } }); layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); //Generic Drug TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug); headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); boolean isAvalaible = false; if (isStoredInLocal) isAvalaible = helper.isAvalaible(drug_name); else isAvalaible = available.equals("Yes"); if (isAvalaible) { ImageView genericDrug = new ImageView(this); genericDrug.setImageResource(R.drawable.tick_verde); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } else { Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); TextView genericDrug = new TextView(this); genericDrug.setTypeface(font); genericDrug.setText("Nd"); genericDrug.setTextColor(getResources().getColor(R.color.maroon)); genericDrug.setTextSize(20); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int size = metrics.widthPixels; int middle = size / 2; int quarter = size / 4; genericDrug.setTranslationX(middle - quarter); genericDrug.setTranslationY(-3); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } //Licenses TextView headerLicense = (TextView) findViewById(R.id.headerLicense); headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); TextView fdaLicense = (TextView) findViewById(R.id.license1); Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); fdaLicense.setTypeface(font); String fda; if (isStoredInLocal) fda = helper.getLicense_FDA(drug_name); else fda = license_FDA; if (fda.equals("Yes")) { fdaLicense.setText("Yes"); fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { fdaLicense.setText("Nd"); fdaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView emaLicense = (TextView) findViewById(R.id.license3); emaLicense.setTypeface(font); String ema; if (isStoredInLocal) ema = helper.getLicense_EMA(drug_name); else ema = license_EMA; if (ema.equals("Yes")) { emaLicense.setText("Yes"); emaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { emaLicense.setText("Nd"); emaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView aempsLicense = (TextView) findViewById(R.id.license2); aempsLicense.setTypeface(font); String aemps; if (isStoredInLocal) aemps = helper.getLicense_AEMPS(drug_name); else aemps = license_AEMPS; if (aemps.equals("Yes")) { aempsLicense.setText("Yes"); aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { aempsLicense.setText("Nd"); aempsLicense.setTextColor(getResources().getColor(R.color.maroon)); } ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug); food_and_drug.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm")); startActivity(intent); } }); ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency); european_medicines_agency.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c")); startActivity(intent); } }); ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps); logo_aemps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm")); startActivity(intent); } }); if (helper.existDrug(drug_name)) { int drug_priority = helper.getDrugPriority(drug_name); ArrayList<String> sorted_drugs = new ArrayList<String>(); sorted_drugs.add(0, drug_name); for (int i = 1; i < drug_priority; i++) { String name = helper.getDrugName(i); sorted_drugs.add(i, name); } for (int i = 0; i < sorted_drugs.size(); i++) helper.setDrugPriority(sorted_drugs.get(i), i + 1); } if (!isStoredInLocal) { //Server code String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=", "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" }; new GetDoseInformation(this).execute(urls); } helper.close(); } }
From source file:eu.geopaparazzi.library.forms.views.GSketchView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent/*from w w w . j a v a2 s.co m*/ * @param key key * @param value value * @param constraintDescription constraints */ public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String key, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); this.noteId = noteId; _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(key.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.draw_sketch); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); Date currentDate = new Date(); String sketchImageName = ImageUtilities.getSketchImageName(currentDate); File tempDir = ResourcesManager.getInstance(getContext()).getTempDir(); File sketchFile = new File(tempDir, sketchImageName); /* * open markers for new sketch */ MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode); } catch (Exception e) { e.printStackTrace(); } } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT, 150); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageLayout.setLayoutParams(imageLayoutParams); // imageLayout.setMinimumHeight(200); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); // scrollView.setFillViewport(true); try { refresh(activity); } catch (Exception e) { GPLog.error(this, null, e); } }
From source file:com.grarak.kerneladiutor.utils.ViewUtils.java
public static Dialog dialogEditTexts(String text, String text2, String hint, String hint2, final DialogInterface.OnClickListener negativeListener, final onDialogEditTextsListener onDialogEditTextListener, Context context) { LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding); layout.setPadding(padding, padding, padding, padding); final AppCompatEditText editText = new AppCompatEditText(context); editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (text != null) { editText.append(text);/*from www. j a va 2s .c om*/ } if (hint != null) { editText.setHint(hint); } editText.setSingleLine(true); final AppCompatEditText editText2 = new AppCompatEditText(context); editText2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); if (text2 != null) { editText2.setText(text2); } if (hint2 != null) { editText2.setHint(hint2); } editText2.setSingleLine(true); layout.addView(editText); layout.addView(editText2); Dialog dialog = new Dialog(context).setView(layout); if (negativeListener != null) { dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener); } if (onDialogEditTextListener != null) { dialog.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogEditTextListener.onClick(editText.getText().toString(), editText2.getText().toString()); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (negativeListener != null) { negativeListener.onClick(dialog, 0); } } }); } return dialog; }
From source file:org.klnusbaum.udj.PullToRefresh.RefreshableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to * be shown when the list is empty./*w ww .java 2s. c o m*/ * * <p> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in * your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ListView lv = new ListView(getActivity()); PullToRefreshListView lv = (PullToRefreshListView) inflater.inflate(R.layout.pull_to_refresh_listview, null); pullToRefreshView = lv; lv.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { // Do work to refresh the list here. doRefreshWork(); } }); // lv.setId(android.R.id.list); // lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:android.support.v7ox.widget.ButtonBarLayout.java
private void setStacked(boolean stacked) { setOrientation(stacked ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL); setGravity(stacked ? Gravity.RIGHT : Gravity.BOTTOM); final View spacer = findViewById(R.id.spacer); if (spacer != null) { spacer.setVisibility(stacked ? View.GONE : View.INVISIBLE); }// w ww . j a va 2 s .co m // Reverse the child order. This is specific to the Material button // bar's layout XML and will probably not generalize. final int childCount = getChildCount(); for (int i = childCount - 2; i >= 0; i--) { bringChildToFront(getChildAt(i)); } }
From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.flashlight.FlashlightService.java
@Override public void onCreate() { sIsRunning = true;//from ww w. j a va 2 s. c om NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getResources().getString(R.string.persistent_flash_active)); builder.setContentText(getResources().getString(R.string.persistent_flash_active_tap)); builder.setSmallIcon(R.drawable.ic_persistent_flash); builder.setContentIntent( PendingIntent.getBroadcast(this, -1, new Intent(getPackageName() + ".STOP_FLASH"), 0)); startForeground(NOTIFICATION_ID, builder.build()); mContainer = new LinearLayout(getApplicationContext()); LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mContainer.setLayoutParams(lparams); mContainer.setOrientation(LinearLayout.VERTICAL); mTurnOffButton = new ImageButton(getApplicationContext()); mTurnOffButton.setImageResource(R.drawable.ic_persistent_flash); mTurnOffButton.setBackgroundColor(0x80000000); mTurnOffButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopSelf(); } }); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = ConstantHolder.getLockscreenType(); params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; params.x = 0; params.y = 0; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = params.width; params.gravity = Gravity.CENTER; params.format = PixelFormat.TRANSLUCENT; mContainer.addView(mTurnOffButton); String method = TogglesResolver.getFlashlightType(getApplicationContext()); if (method.equals("default")) { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } else if (method.equals("htc")) { mFlashManipulator = new HTCFlashlightManipulator(); } else if (method.equals("nosurfaceview")) { mFlashManipulator = new NoSurfaceViewFlashlightManipulator(); } else { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } mWindowManager.addView(mContainer, params); mHandler = new Handler(); mActor = new Runnable() { @Override public void run() { mFlashManipulator.turnFlashlightOn(); } }; mScreenOffReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); mHandler.postDelayed(mActor, 200); } }; mStopServiceReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); stopSelf(); } }; registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mStopServiceReceiver, new IntentFilter(getPackageName() + ".STOP_FLASH")); }
From source file:com.tony.selene.sliding.AbSlidingSmoothTabView.java
/** * Instantiates a new ab sliding smooth tab view. * * @param context/*from w w w.j a v a 2 s . c o m*/ * the context * @param attrs * the attrs */ public AbSlidingSmoothTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabScrollView = new AbHorizontalScrollView(context); mTabScrollView.setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); // mTabLayout mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT)); // Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabScrollView, layoutParamsFW); // ? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); // View? mViewPager = new ViewPager(context); // ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); // ?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbSlidingSmoothTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); mTabScrollView.setSmoothScrollingEnabled(true); mTabScrollView.setOnScrollListener(new AbOnScrollListener() { @Override public void onScrollToRight() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToRight"); } @Override public void onScrollToLeft() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToLeft"); } @Override public void onScrollStoped() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollStoped"); } @Override public void onScroll(int arg1) { scrollX = arg1; View view = mTabLayout.getChildAt(mSelectedTabIndex); int toX = view.getLeft() - scrollX; AbLogUtil.d(AbSlidingSmoothTabView.class, "X" + startX + "to" + toX); imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } }); }
From source file:org.odk.collect.android.fragments.dialogs.RankingWidgetDialog.java
private LinearLayout setUpPositionsLayout(List<String> values) { LinearLayout positionsLayout = new LinearLayout(getContext()); positionsLayout.setOrientation(LinearLayout.VERTICAL); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, 0, 10, 0); positionsLayout.setLayoutParams(layoutParams); for (String value : values) { FrameLayout positionLayout = (FrameLayout) LayoutInflater.from(getContext()) .inflate(R.layout.ranking_item, positionsLayout, false); TextView textView = positionLayout.findViewById(R.id.rank_item_text); textView.setText(String.valueOf(values.indexOf(value) + 1)); textView.setTextSize(Collect.getQuestionFontsize()); positionsLayout.addView(positionLayout); }//from w w w .ja v a 2 s.c o m return positionsLayout; }
From source file:com.auth0.android.lock.views.FormLayout.java
private void init() { boolean showSocial = !lockWidget.getConfiguration().getSocialConnections().isEmpty(); showDatabase = lockWidget.getConfiguration().getDatabaseConnection() != null; showEnterprise = !lockWidget.getConfiguration().getEnterpriseConnections().isEmpty(); boolean showModeSelection = showDatabase && lockWidget.getConfiguration().allowLogIn() && lockWidget.getConfiguration().allowSignUp(); int verticalMargin = getResources() .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field); int horizontalMargin = getResources() .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin); if (showModeSelection) { Log.v(TAG, "Showing the LogIn/SignUp tabs"); modeSelectionView = new ModeSelectionView(getContext(), this); modeSelectionView.setId(R.id.com_auth0_lock_form_selector); LayoutParams modeSelectionParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); modeSelectionParams.addRule(ALIGN_PARENT_TOP); addView(modeSelectionView, modeSelectionParams); }//from w w w . j av a 2 s . c om formsHolder = new LinearLayout(getContext()); formsHolder.setOrientation(LinearLayout.VERTICAL); formsHolder.setGravity(Gravity.CENTER); formsHolder.setPadding(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin); LayoutParams holderParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); holderParams.addRule(BELOW, R.id.com_auth0_lock_form_selector); holderParams.addRule(CENTER_VERTICAL); addView(formsHolder, holderParams); if (showSocial) { addSocialLayout(); if (showDatabase || showEnterprise) { addSeparator(); } } displayInitialScreen(); }
From source file:nz.ac.auckland.lablet.script.SheetGroupLayoutParameters.java
protected void add(Context context, Fragment parentFragment, SheetLayout item, boolean isLast) { View view = item.buildLayout(context, parentFragment); // set width to zero so that the table layout stretches all columns evenly view.setLayoutParams(/* ww w .ja va 2s. co m*/ new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, item.getParameters().getWeight())); row.addView(view); int xPadding = 20; int yPadding = 20; if (orientation == LinearLayout.VERTICAL) { row = new TableRow(context); layout.addView(row); if (isLast) yPadding = 0; } else if (isLast) xPadding = 0; view.setPadding(0, 0, xPadding, yPadding); }