List of usage examples for android.widget LinearLayout addView
public void addView(View child, int width, int height)
From source file:com.gao.im.ui.CCPActivityBase.java
public void init(Context context, FragmentActivity activity) { mActionBarActivity = activity;//ww w. ja va2 s .co m onInit(); mAudioManager = AudioManagerTools.getInstance().getAudioManager(); mMusicMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int layoutId = getLayoutId(); mLayoutInflater = LayoutInflater.from(mActionBarActivity); mBaseLayoutView = mLayoutInflater.inflate(R.layout.ccp_activity, null); mTransLayerView = mBaseLayoutView.findViewById(R.id.ccp_trans_layer); LinearLayout mRootView = (LinearLayout) mBaseLayoutView.findViewById(R.id.ccp_root_view); mContentFrameLayout = (FrameLayout) mBaseLayoutView.findViewById(R.id.ccp_content_fl); if (getTitleLayout() != -1) { mTopBarView = mLayoutInflater.inflate(getTitleLayout(), null); mRootView.addView(mTopBarView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); } if (layoutId != -1) { mContentView = getContentLayoutView(); if (mContentView == null) { mContentView = mLayoutInflater.inflate(getLayoutId(), null); } mRootView.addView(mContentView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); } onBaseContentViewAttach(mBaseLayoutView); CCPLayoutListenerView listenerView = (CCPLayoutListenerView) mActionBarActivity .findViewById(R.id.ccp_content_fl); if (listenerView != null && mActionBarActivity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { listenerView.setOnSizeChangedListener(new CCPLayoutListenerView.OnCCPViewSizeChangedListener() { @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { LogUtil.d(LogUtil.getLogUtilsTag(getClass()), "oldh - h = " + (oldh - h)); } }); } CCPAppManager.setContext(mActionBarActivity); }
From source file:com.darly.im.ui.CCPActivityBase.java
public void init(Context context, FragmentActivity activity) { mActionBarActivity = activity;/*w ww . ja v a 2 s. co m*/ onInit(); mAudioManager = AudioManagerTools.getInstance().getAudioManager(); mMusicMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int layoutId = getLayoutId(); mLayoutInflater = LayoutInflater.from(mActionBarActivity); mBaseLayoutView = mLayoutInflater.inflate(R.layout.ccp_activity, null); mTransLayerView = mBaseLayoutView.findViewById(R.id.ccp_trans_layer); LinearLayout mRootView = (LinearLayout) mBaseLayoutView.findViewById(R.id.ccp_root_view); mContentFrameLayout = (FrameLayout) mBaseLayoutView.findViewById(R.id.ccp_content_fl); if (getTitleLayout() != -1) { mTopBarView = mLayoutInflater.inflate(getTitleLayout(), null); mRootView.addView(mTopBarView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } if (layoutId != -1) { mContentView = getContentLayoutView(); if (mContentView == null) { mContentView = mLayoutInflater.inflate(getLayoutId(), null); } mRootView.addView(mContentView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); } dealContentView(mBaseLayoutView); CCPLayoutListenerView listenerView = (CCPLayoutListenerView) mActionBarActivity .findViewById(R.id.ccp_content_fl); if (listenerView != null && mActionBarActivity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { listenerView.setOnSizeChangedListener(new CCPLayoutListenerView.OnCCPViewSizeChangedListener() { @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { LogUtil.d(LogUtil.getLogUtilsTag(getClass()), "oldh - h = " + (oldh - h)); } }); } }
From source file:com.astuetz.PagerSlidingTabStripPlus.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/*from w w w . j a v a2 s.c o m*/ tab.setPadding(tabPaddingLeft, tabPaddingTop, tabPaddingRight, tabPaddingBottom); LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.VERTICAL); tabLayout.setGravity(Gravity.CENTER); tabLayout.addView(tab, 0, defaultTabLayoutParams); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tabLayout, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java
/** add one number indicator tab */ private void addNumTab(final int position, String title, int num) { LinearLayout tab = new LinearLayout(getContext()); TextView titleText = new TextView(getContext()); TextView numText = new TextView(getContext()); titleText.setText(title);//from ww w .j a v a 2 s . com titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); numText.setText(Integer.toString(num)); numText.setGravity(Gravity.CENTER); numText.setPadding(mNumPadding, 1, mNumPadding, 1); numText.setSingleLine(); /* if the number is 0, set invisible */ if (num == 0) { numText.setVisibility(View.GONE); } else { numText.setVisibility(View.VISIBLE); } tab.addView(titleText, 0, mDefaultTabLayoutParams); tab.addView(numText, 1, mNumLayoutParams); tab.setGravity(Gravity.CENTER); addTab(position, tab); }
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 ww . j a v a 2s.c om 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:com.flowzr.activity.RecurActivity.java
private void addLayouts(LayoutInflater inflater, LinearLayout layout, Layoutable[] items) { for (Layoutable i : items) { int layoutId = i.getLayoutId(); if (layoutId != 0) { final View v = inflater.inflate(layoutId, null); v.setTag(i);/*from ww w. ja v a 2s . c om*/ v.setVisibility(View.INVISIBLE); if (i == RecurPeriod.STOPS_ON_DATE) { Button b = (Button) v.findViewById(R.id.bStopsOnDate); final Calendar c = this.stopsOnDate; editStopsOnDate(v, c.getTimeInMillis()); b.setOnClickListener(new OnClickListener() { @Override public void onClick(final View view) { DatePickerDialog d = new DatePickerDialog(RecurActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.endOfDay(c); editStopsOnDate(v, c.getTimeInMillis()); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); } layout.addView(v, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); } } }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public void additionalInformationInterface(String option, String drug_name, String group_name, ArrayList<String> notesIndex, ArrayList<Article_Reference> referencesIndex) { LinearLayout borderLayout = createBorderLayout(); ArrayList<String> notes = new ArrayList<String>(); if (option.equals("GENERAL NOTES")) { SQLiteDatabase db = helper.open(); if (db != null) { notes = helper.read_general_notes(drug_name, group_name); helper.close();/*from ww w .j a v a 2s .c o m*/ } } else if (option.equals("SPECIFIC NOTES")) { notes = notesIndex; } if (((option.equals("GENERAL NOTES") || option.equals("SPECIFIC NOTES")) && notes.size() > 0) || (option.equals("REFERENCES") && referencesIndex.size() > 0)) { TextView titleTextView = createTitleTextView(); titleTextView.setText(option); LinearLayout.LayoutParams params = createTextViewParams("Title TextView"); layoutDose.addView(titleTextView, layoutDose.getChildCount(), params); if (option.equals("GENERAL NOTES") || option.equals("SPECIFIC NOTES")) { for (int i = 0; i < notes.size(); i++) { TextView informationTextView = createInformationTextView(); if (option.equals("GENERAL NOTES")) informationTextView.setText(" " + notes.get(i)); else informationTextView.setText("(" + (i + 1) + ") " + notesIndex.get(i)); LinearLayout.LayoutParams informationParams = createTextViewParams("Information TextView"); borderLayout.addView(informationTextView, borderLayout.getChildCount(), informationParams); } } else { for (int i = 0; i < referencesIndex.size(); i++) { TextView informationTextView = createInformationTextView(); informationTextView.setText( "(" + referencesIndex.get(i).getIndex() + ") " + referencesIndex.get(i).getArticle()); LinearLayout.LayoutParams informationParams = createTextViewParams("Information TextView"); borderLayout.addView(informationTextView, borderLayout.getChildCount(), informationParams); } } } layoutDose.addView(borderLayout, layoutDose.getChildCount()); }
From source file:com.ichi2.anki.multimediacard.fields.BasicImageFieldController.java
@Override public void createUI(Context context, LinearLayout layout) { mImagePreview = new ImageView(mActivity); DisplayMetrics metrics = getDisplayMetrics(); int height = metrics.heightPixels; int width = metrics.widthPixels; LinearLayout.LayoutParams p = new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); setPreviewImage(mField.getImagePath(), getMaxImageSize()); mImagePreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mImagePreview.setAdjustViewBounds(true); mImagePreview.setMaxHeight((int) Math.round(height * 0.4)); mImagePreview.setMaxWidth((int) Math.round(width * 0.6)); mBtnGallery = new Button(mActivity); mBtnGallery.setText(gtxt(R.string.multimedia_editor_image_field_editing_galery)); mBtnGallery.setOnClickListener(new View.OnClickListener() { @Override/*w w w . j a va 2 s. c o m*/ public void onClick(View v) { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); mActivity.startActivityForResult(i, ACTIVITY_SELECT_IMAGE); } }); mBtnCamera = new Button(mActivity); mBtnCamera.setText(gtxt(R.string.multimedia_editor_image_field_editing_photo)); mBtnCamera.setOnClickListener(new View.OnClickListener() { @SuppressLint("NewApi") @Override public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File image; File storageDir; String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(new Date()); try { storageDir = mActivity.getCacheDir(); image = File.createTempFile("img_" + timeStamp, ".jpg", storageDir); mTempCameraImagePath = image.getPath(); Uri uriSavedImage = FileProvider.getUriForFile(mActivity, mActivity.getApplicationContext().getPackageName() + ".apkgfileprovider", image); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); mActivity.startActivityForResult(cameraIntent, ACTIVITY_TAKE_PICTURE); } catch (IOException e) { e.printStackTrace(); } } }); // Chromebooks do not support camera capture yet. if (CompatHelper.isChromebook()) { mBtnCamera.setVisibility(View.INVISIBLE); } layout.addView(mImagePreview, android.view.ViewGroup.LayoutParams.FILL_PARENT, p); layout.addView(mBtnGallery, android.view.ViewGroup.LayoutParams.FILL_PARENT); layout.addView(mBtnCamera, android.view.ViewGroup.LayoutParams.FILL_PARENT); }
From source file:com.processing.core.PApplet.java
/** Called with the activity is first created. */ @Override//from w w w . j a v a 2s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // println("PApplet.onCreate()"); if (DEBUG) println("onCreate() happening here: " + Thread.currentThread().getName()); Window window = getWindow(); // Take up as much area as possible requestWindowFeature(Window.FEATURE_NO_TITLE); window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); // This does the actual full screen work window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); displayWidth = dm.widthPixels; displayHeight = dm.heightPixels; // println("density is " + dm.density); // println("densityDpi is " + dm.densityDpi); if (DEBUG) println("display metrics: " + dm); //println("screen size is " + screenWidth + "x" + screenHeight); // LinearLayout layout = new LinearLayout(this); // layout.setOrientation(LinearLayout.VERTICAL | LinearLayout.HORIZONTAL); // viewGroup = new ViewGroup(); // surfaceView.setLayoutParams(); // viewGroup.setLayoutParams(LayoutParams.) // RelativeLayout layout = new RelativeLayout(this); // RelativeLayout overallLayout = new RelativeLayout(this); // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT); //lp.addRule(RelativeLayout.RIGHT_OF, tv1.getId()); // layout.setGravity(RelativeLayout.CENTER_IN_PARENT); int sw = sketchWidth(); int sh = sketchHeight(); if (sketchRenderer().equals(JAVA2D)) { surfaceView = new SketchSurfaceView(this, sw, sh); } else if (sketchRenderer().equals(P2D) || sketchRenderer().equals(P3D)) { surfaceView = new SketchSurfaceViewGL(this, sw, sh, sketchRenderer().equals(P3D)); } // g = ((SketchSurfaceView) surfaceView).getGraphics(); // surfaceView.setLayoutParams(new LayoutParams(sketchWidth(), sketchHeight())); // layout.addView(surfaceView); // surfaceView.setVisibility(1); // println("visibility " + surfaceView.getVisibility() + " " + SurfaceView.VISIBLE); // layout.addView(surfaceView); // AttributeSet as = new AttributeSet(); // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(layout, as); // lp.addRule(android.R.styleable.ViewGroup_Layout_layout_height, // layout.add //lp.addRule(, arg1) //layout.addView(surfaceView, sketchWidth(), sketchHeight()); // new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.FILL_PARENT); if (sw == displayWidth && sh == displayHeight) { // If using the full screen, don't embed inside other layouts window.setContentView(surfaceView); } else { // If not using full screen, setup awkward view-inside-a-view so that // the sketch can be centered on screen. (If anyone has a more efficient // way to do this, please file an issue on Google Code, otherwise you // can keep your "talentless hack" comments to yourself. Ahem.) RelativeLayout overallLayout = new RelativeLayout(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); LinearLayout layout = new LinearLayout(this); layout.addView(surfaceView, sketchWidth(), sketchHeight()); overallLayout.addView(layout, lp); window.setContentView(overallLayout); } /* // Here we use Honeycomb API (11+) to hide (in reality, just make the status icons into small dots) // the status bar. Since the core is still built against API 7 (2.1), we use introspection to get // the setSystemUiVisibility() method from the view class. Method visibilityMethod = null; try { visibilityMethod = surfaceView.getClass().getMethod("setSystemUiVisibility", new Class[] { int.class}); } catch (NoSuchMethodException e) { // Nothing to do. This means that we are running with a version of Android previous to Honeycomb. } if (visibilityMethod != null) { try { // This is equivalent to calling: //surfaceView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); // The value of View.STATUS_BAR_HIDDEN is 1. visibilityMethod.invoke(surfaceView, new Object[] { 1 }); } catch (InvocationTargetException e) { } catch (IllegalAccessException e) { } } window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); */ // layout.addView(surfaceView, lp); // surfaceView.setLayoutParams(new LayoutParams(sketchWidth(), sketchHeight())); // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams() // layout.addView(surfaceView, new LayoutParams(arg0) // TODO probably don't want to set these here, can't we wait for surfaceChanged()? // removing this in 0187 // width = screenWidth; // height = screenHeight; // int left = (screenWidth - iwidth) / 2; // int right = screenWidth - (left + iwidth); // int top = (screenHeight - iheight) / 2; // int bottom = screenHeight - (top + iheight); // surfaceView.setPadding(left, top, right, bottom); // android:layout_width // window.setContentView(surfaceView); // set full screen // code below here formerly from init() //millisOffset = System.currentTimeMillis(); // moved to the variable declaration finished = false; // just for clarity // this will be cleared by draw() if it is not overridden looping = true; redraw = true; // draw this guy once // firstMotion = true; Context context = getApplicationContext(); sketchPath = context.getFilesDir().getAbsolutePath(); // Looper.prepare(); handler = new Handler(); // println("calling loop()"); // Looper.loop(); // println("done with loop() call, will continue..."); start(); }