List of usage examples for android.widget LinearLayout addView
public void addView(View child, int index)
From source file:se.anyro.nfc_reader.TagViewer.java
void buildTagViews(NdefMessage[] msgs) { if (msgs == null || msgs.length == 0) { return;// w ww . j av a 2s.c om } LayoutInflater inflater = LayoutInflater.from(this); LinearLayout content = mTagContent; // Parse the first message in the list // Build views for all of the sub records Date now = new Date(); List<ParsedNdefRecord> records = NdefMessageParser.parse(msgs[0]); final int size = records.size(); for (int i = 0; i < size; i++) { TextView timeView = new TextView(this); timeView.setText(TIME_FORMAT.format(now)); content.addView(timeView, 0); ParsedNdefRecord record = records.get(i); content.addView(record.getView(this, inflater, content, i), 1 + i); content.addView(inflater.inflate(R.layout.tag_divider, content, false), 2 + i); } }
From source file:com.cssweb.android.quote.QuoteDetail.java
/** * ???/*from w w w. j a v a 2s . c om*/ */ private void initLoading() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.HORIZONTAL); ProgressBar progressBar = new ProgressBar(this); progressBar.setPadding(0, 0, 15, 0); LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LayoutParams layoutParams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); layout.addView(progressBar, layoutParams); TextView textView = new TextView(this); textView.setText(getResources().getText(R.string.cjmx_loading)); textView.setGravity(Gravity.CENTER_VERTICAL); layout.addView(textView, layoutParams2); layout.setGravity(Gravity.CENTER); loadingLayout = new LinearLayout(this); loadingLayout.addView(layout, layoutParams); loadingLayout.setGravity(Gravity.CENTER); table_1.addView(loadingLayout, 0); }
From source file:com.aimfire.intro.IntroductionActivity.java
@SuppressWarnings("deprecation") public void addDots() { dots = new ArrayList<ImageView>(); LinearLayout dotsLayout = (LinearLayout) findViewById(R.id.dots); for (int i = 0; i < NUM_PAGES; i++) { ImageView dot = new ImageView(this); dot.setImageDrawable(getResources().getDrawable(R.drawable.pager_dot_not_selected)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(20, 0, 20, 0); dotsLayout.addView(dot, params); dots.add(dot);// w w w. j a va2 s . c o m } mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { updateNavBar(position); } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.starwood.anglerslong.LicenseActivity.java
private void createTextView() { if (isCreateTextViewSet) return;/*from w w w .ja v a 2s.c o m*/ // Get the linear layout and set the parameters LinearLayout ll = (LinearLayout) findViewById(R.id.profile_ll); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; TextView createLicense = new TextView(this); createLicense.setId(0); createLicense.setText(Html.fromHtml(getResources().getString(R.string.create_license_string))); createLicense.setPadding(70, 100, 70, 100); createLicense.setTextSize(18); ll.addView(createLicense, params); isCreateTextViewSet = true; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE TITLE ROW/*w w w .j a va 2s .c om*/ * @param att * @param linear * @return */ public LinearLayout getSingleTitleRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setMinimumHeight(30); container_layout .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue)); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView t1 = new TextView(context); t1.setText(att.get("value")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t1, ltext1); linear.addView(container_layout); return linear; }
From source file:com.cmput301.recipebot.ui.AbstractRecipeActivity.java
/** * A method that fills a {@link LinearLayout} with data from a List of data. * We don't use {@link android.widget.ListView} since we don't need scrolling, our {@link android.widget.ScrollView} handles * that for us.// www. ja v a 2 s . c o m * * @param listDirections the layout to fill * @param dataset the data that should be displayed. */ protected void fillListLayout(LinearLayout listDirections, List dataset, int type) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); //Sanitize the view listDirections.removeAllViews(); for (int i = 0; i < dataset.size(); i++) { Object data = dataset.get(i); CheckBox checkBox = (CheckBox) layoutInflater.inflate(R.layout.checkbox_view, null); checkBox.setText(data.toString()); TaggedItem item = new TaggedItem(); item.type = type; item.data = data; checkBox.setTag(item); checkBox.setOnCheckedChangeListener(this); listDirections.addView(checkBox, i); } }
From source file:com.t2.androidspineexample.AndroidSpineExampleActivity.java
private void generateChart() { // Set up chart XYMultipleSeriesDataset deviceDataset = new XYMultipleSeriesDataset(); XYMultipleSeriesRenderer deviceRenderer = new XYMultipleSeriesRenderer(); LinearLayout layout = (LinearLayout) findViewById(R.id.deviceChart); if (mDeviceChartView != null) { layout.removeView(mDeviceChartView); }// w ww .ja v a 2 s .c o m if (true) { mDeviceChartView = ChartFactory.getLineChartView(this, deviceDataset, deviceRenderer); mDeviceChartView.setBackgroundColor(Color.BLACK); layout.addView(mDeviceChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } deviceRenderer.setShowLabels(false); deviceRenderer.setMargins(new int[] { 0, 5, 5, 0 }); deviceRenderer.setShowAxes(true); deviceRenderer.setShowLegend(false); deviceRenderer.setZoomEnabled(false, false); deviceRenderer.setPanEnabled(false, false); deviceRenderer.setYAxisMin(0); // deviceRenderer.setYAxisMax(1000); // This is set rather arbitrarily based on observed resistance values in the log deviceRenderer.setYAxisMax(8000000); deviceDataset.addSeries(mSeries); XYSeriesRenderer seriesRenderer = new XYSeriesRenderer(); seriesRenderer.setColor(Color.WHITE); seriesRenderer.setPointStyle(PointStyle.CIRCLE); deviceRenderer.addSeriesRenderer(seriesRenderer); }
From source file:com.gandulf.guilib.view.adapter.MultiFragmentPagerAdapter.java
@Override public Object instantiateItem(View container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }/*w ww .j ava 2s .c o m*/ LinearLayout v = new LinearLayout(mContext); v.setOrientation(LinearLayout.HORIZONTAL); v.setWeightSum(getCount(position)); int startIndex = getStartIndex(position); int containerId = 0; final int size = getCount(position); for (int i = 0; i < size; i++) { containerId = startIndex + i; String name = makeFragmentName(container.getId(), containerId); Fragment fragment = mFragmentManager.findFragmentByTag(name); FrameLayout fragmentView = new FrameLayout(mContext); LayoutParams layoutParams = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1); fragmentView.setLayoutParams(layoutParams); fragmentView.setId(containerId); v.addView(fragmentView, i); if (fragment != null) { Debug.verbose("Attaching item #" + position + ": f=" + fragment + " id:" + containerId); mCurTransaction.attach(fragment); } else { // index is 1 based remove 1 to get a 0-based fragment = getItem(position, i); if (fragment != null) { Debug.verbose("Adding item #" + position + ": f=" + fragment + " id:" + containerId); mCurTransaction.add(containerId, fragment, name); } } if (fragment != null && !mCurrentPrimaryItems.contains(fragment)) { fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); } } mCurTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ((ViewPager) container).addView(v, 0); return v; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TITLE ROW//from www.ja v a 2s . c o m * @param att * @param linear * @return */ public LinearLayout getDoubleTitleRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setMinimumHeight(30); container_layout .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue)); container_layout.setVerticalGravity(Gravity.CENTER); container_layout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(""); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t1, ltext1); LinearLayout.LayoutParams ltext2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setText(att.get("value2")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t2, ltext2); linear.addView(container_layout); return linear; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE IMAGE ROW/*from w w w. j a v a 2 s. c o m*/ * @param att * @param linear * @return */ public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f); ImageView img = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value")); img.setImageResource(context.getResources().getIdentifier(path, null, null)); img.setPadding(0, 3, 0, 3); container_layout.addView(img, value_params); linear.addView(container_layout); return linear; }