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:nuclei.ui.view.ButtonBarView.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ButtonBarView, defStyleAttr, defStyleRes);/*from w w w . java 2s.co m*/ final boolean bottom = a.getBoolean(R.styleable.ButtonBarView_bottom, false); final int layout = a.getResourceId(R.styleable.ButtonBarView_control_layout, bottom ? R.layout.cyto_view_button_bar_bottom : R.layout.cyto_view_button_bar); final View view = LayoutInflater.from(context).inflate(layout, this, false); addView(view); mButtons = (LinearLayout) view.findViewById(R.id.buttons); mOrientation = a.getInt(R.styleable.ButtonBarView_control_orientation, 1); switch (mOrientation) { case 1: mButtons.setOrientation(LinearLayout.HORIZONTAL); break; case 2: mButtons.setOrientation(LinearLayout.VERTICAL); break; } mSelectedTint = a.getColor(R.styleable.ButtonBarView_selected_color, ResourcesCompat.getColor(getResources(), R.color.black, context.getTheme())); mUnselectedTint = a.getColor(R.styleable.ButtonBarView_unselected_color, ResourcesCompat.getColor(getResources(), R.color.grey, context.getTheme())); if (a.hasValue(R.styleable.ButtonBarView_buttons_background)) { final int color = a.getColor(R.styleable.ButtonBarView_buttons_background, Color.WHITE); View v = view.findViewById(R.id.buttons_container); if (v != null) v.setBackgroundColor(color); else mButtons.setBackgroundColor(color); } a.recycle(); }
From source file:eu.hydrologis.geopaparazzi.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = context.getResources().getColor(R.color.formbgcolor); int textColor = context.getResources().getColor(R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from ww w .jav a 2s . c om scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); DataType type = DataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final EditText editView = new EditText(context); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setText(value); // editView.setEnabled(!isReadOnly); editView.setFocusable(!isReadOnly); // editView.setTextAppearance(context, android.R.style.TextAppearance_Medium); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } switch (type) { case DOUBLE: case FLOAT: editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; case PHONE: editView.setInputType(InputType.TYPE_CLASS_PHONE); break; case DATE: editView.setInputType(InputType.TYPE_CLASS_DATETIME); break; case INTEGER: editView.setInputType(InputType.TYPE_CLASS_NUMBER); break; default: break; } editView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // ignore } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } public void afterTextChanged(Editable s) { String text = editView.getText().toString(); feature.setAttribute(name, text); } }); linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText("Area: " + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText("Length: " + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java
/** * Instantiates a new ab sliding smooth fix tab view. * * @param context the context/*w w w . j av a 2s . c om*/ * @param attrs the attrs */ public ESSlidingSmoothFixTabView(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); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabLayout, 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)) { ESLogUtil.e(ESSlidingSmoothFixTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = ESAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:me.diskstation.ammon.gpsrunner.ui.RunDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_run_details, container, false); context = getActivity();/*from w w w . j a va 2s .c o m*/ //Get all Layouts LinearLayout distanceLayout = (LinearLayout) view.findViewById(R.id.distanceLayout); LinearLayout timeIntervalLayout = (LinearLayout) view.findViewById(R.id.intervalLayout); LinearLayout maxVelocityLayout = (LinearLayout) view.findViewById(R.id.maxVelocityLayout); LinearLayout avgVelocityLayout = (LinearLayout) view.findViewById(R.id.avgVelocityLayout); LinearLayout ascentLayout = (LinearLayout) view.findViewById(R.id.ascIntervalLayout); LinearLayout descentLayout = (LinearLayout) view.findViewById(R.id.descIntervalLayout); LinearLayout breakTimeLayout = (LinearLayout) view.findViewById(R.id.totalBreakLayout); //Generate all the value layouts LinearLayout distanceValueLayout = new LinearLayout(context); distanceValueLayout.setOrientation(LinearLayout.VERTICAL); distanceLayout.addView(distanceValueLayout); LinearLayout timeIntervalValueLayout = new LinearLayout(context); timeIntervalValueLayout.setOrientation(LinearLayout.VERTICAL); timeIntervalLayout.addView(timeIntervalValueLayout); LinearLayout maxVelocityValueLayout = new LinearLayout(context); maxVelocityValueLayout.setOrientation(LinearLayout.VERTICAL); maxVelocityLayout.addView(maxVelocityValueLayout); LinearLayout avgVelocityValueLayout = new LinearLayout(context); avgVelocityValueLayout.setOrientation(LinearLayout.VERTICAL); avgVelocityLayout.addView(avgVelocityValueLayout); LinearLayout ascentValueLayout = new LinearLayout(context); ascentValueLayout.setOrientation(LinearLayout.VERTICAL); ascentLayout.addView(ascentValueLayout); LinearLayout descentValueLayout = new LinearLayout(context); descentValueLayout.setOrientation(LinearLayout.VERTICAL); descentLayout.addView(descentValueLayout); LinearLayout breakTimeValueLayout = new LinearLayout(context); breakTimeValueLayout.setOrientation(LinearLayout.VERTICAL); breakTimeLayout.addView(breakTimeValueLayout); //populate Layouts with TextViews and values for (int i = 0; i < runs.size(); i++) { Run run = runs.get(i); //set up all TextViews TextView distanceView = new TextView(context); distanceView.setText(vf.formatDistance(run.distance)); setUpTextView(distanceView, i); TextView timeIntervalView = new TextView(context); timeIntervalView.setText(vf.formatTimeInterval(run.timeInterval)); setUpTextView(timeIntervalView, i); TextView maxVelocityView = new TextView(context); maxVelocityView.setText(vf.formatVelocity(run.maxVelocity)); setUpTextView(maxVelocityView, i); TextView avgVelocityView = new TextView(context); avgVelocityView.setText(vf.formatVelocity(run.medVelocity)); setUpTextView(avgVelocityView, i); TextView ascentView = new TextView(context); ascentView.setText(vf.formatDistance(run.ascendInterval)); setUpTextView(ascentView, i); TextView descentView = new TextView(context); descentView.setText(vf.formatDistance(run.descendInterval)); setUpTextView(descentView, i); TextView breakView = new TextView(context); breakView.setText(vf.formatTimeInterval(run.breakTime)); setUpTextView(breakView, i); //add TextViews to value layouts distanceValueLayout.addView(distanceView); timeIntervalValueLayout.addView(timeIntervalView); maxVelocityValueLayout.addView(maxVelocityView); avgVelocityValueLayout.addView(avgVelocityView); ascentValueLayout.addView(ascentView); descentValueLayout.addView(descentView); breakTimeValueLayout.addView(breakView); } return view; }
From source file:net.peterkuterna.android.apps.devoxxsched.ui.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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.//from w w w. j ava 2s . com * * <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 GridFragment. 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 gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, 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:gov.sfmta.sfpark.DetailViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.detailview); if (annotation == null) { Log.v(TAG, "annotation is null"); return;/*from w ww .j a v a 2s. c o m*/ } // Set up ActionBar ActionBar ab = getSupportActionBar(); ab.setDisplayShowTitleEnabled(true); ab.setTitle(" :: " + annotation.title); ab.setIcon(R.drawable.logo_header); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); ab.setDisplayHomeAsUpEnabled(true); detailName = (TextView) findViewById(R.id.detailName); detailName.setText(annotation.title.toUpperCase()); garageUse = (TextView) findViewById(R.id.usageText); garageUse.setText(annotation.subtitle); View availColor = findViewById(R.id.blockColor); availColor.setBackgroundColor( annotation.onStreet ? annotation.blockColorAvailability : annotation.garageColor); if (!annotation.onStreet) { addressLabel = (TextView) findViewById(R.id.addressText); phoneTextView = (TextView) findViewById(R.id.phoneText); addressLabel.setVisibility(View.VISIBLE); phoneTextView.setVisibility(View.VISIBLE); String str; str = annotation.allGarageData.optString("DESC") + " (" + annotation.allGarageData.optString("INTER") + ")"; if (str != null) { addressLabel.setText(str); } str = annotation.allGarageData.optString("TEL"); if (str != null) { phoneTextView.setText(str); } } listLayout = (LinearLayout) findViewById(R.id.detailLinearLayout); listLayout.setOrientation(LinearLayout.VERTICAL); try { parseHours(); parseRates(); parseInfo(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * Instantiates a new ab sliding smooth fix tab view. * * @param context the context/*from w w w . j av a 2s . co m*/ * @param attrs the attrs */ public AbSlidingSmoothFixTabView(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); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabLayout, 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(AbSlidingSmoothFixTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.yamin.kk.fragment.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a GridView 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./*from w ww . j a v a 2 s .c om*/ * * <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 GridFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @SuppressWarnings("deprecation") @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 gframe = new FrameLayout(context); gframe.setId(INTERNAL_GRID_CONTAINER_ID); TextView tv = new TextView(context); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); gframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView gv = new GridView(context); gv.setId(android.R.id.list); gv.setDrawSelectorOnTop(false); gframe.addView(gv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(gframe, 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:net.pocketmagic.android.eventinjector.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LT, "App created."); Events.intEnableDebug(1);// w w w . j av a2 s .c o m // disable the titlebar requestWindowFeature(Window.FEATURE_NO_TITLE); // create a basic user interface LinearLayout panel = new LinearLayout(this); panel.setOrientation(LinearLayout.VERTICAL); setContentView(panel); EditText v = new EditText(this); v.setId(idTextView); v.setOnClickListener(this); panel.addView(v); // -- Button b = new Button(this); b.setText("Scan Input Devs"); b.setId(idButScan); b.setOnClickListener(this); panel.addView(b); // put list in a scroll view LinearLayout listLayout = new LinearLayout(this); listLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); m_lvDevices = new ListView(this); LayoutParams lvLayoutParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); m_lvDevices.setLayoutParams(lvLayoutParam); m_lvDevices.setId(idLVDevices); m_lvDevices.setDividerHeight(0); m_lvDevices.setFadingEdgeLength(0); m_lvDevices.setCacheColorHint(0); m_lvDevices.setAdapter(null); listLayout.addView(m_lvDevices); panel.addView(listLayout); // -- LinearLayout panelH = new LinearLayout(this); panelH.setOrientation(LinearLayout.HORIZONTAL); panel.addView(panelH); // -- m_selDevSpinner = new Spinner(this); m_selDevSpinner.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); m_selDevSpinner.setId(idSelSpin); m_selDevSpinner.setOnItemSelectedListener((OnItemSelectedListener) this); panelH.addView(m_selDevSpinner); // -- simulate key event b = new Button(this); b.setText(">Key"); b.setId(idButInjectKey); b.setOnClickListener(this); panelH.addView(b); // -- simulate touch event b = new Button(this); b.setText(">Tch"); b.setId(idButInjectTouch); b.setOnClickListener(this); panelH.addView(b); // -- m_tvMonitor = new TextView(this); m_tvMonitor.setText("Event Monitor stopped."); panel.addView(m_tvMonitor); // -- panelH = new LinearLayout(this); panelH.setOrientation(LinearLayout.HORIZONTAL); panel.addView(panelH); // -- b = new Button(this); b.setText("Monitor Start"); b.setId(idButMonitorStart); b.setOnClickListener(this); panelH.addView(b); // -- b = new Button(this); b.setText("Monitor Stop"); b.setId(idButMonitorStop); b.setOnClickListener(this); panelH.addView(b); // -- simulate test event b = new Button(this); b.setText(">Test"); b.setId(idButTest); b.setOnClickListener(this); panelH.addView(b); }
From source file:by.istin.android.xcore.inherited.fragment.AdapterViewFragment.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. * /*from w w w .j a va 2 s.com*/ * <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.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_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.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); AdapterView<?> adapterView = createDefaultAbstractView(); adapterView.setId(android.R.id.list); if (adapterView instanceof ListView) { ((ListView) adapterView).setDrawSelectorOnTop(false); } lframe.addView(adapterView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }