List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.android.settings.widget.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs) { super(context, attrs); mLayoutInflater = LayoutInflater.from(context); mTitleView = new LinearLayout(context); mTitleView.setGravity(Gravity.CENTER_HORIZONTAL); mIndicatorView = mLayoutInflater.inflate(R.layout.sliding_tab_indicator_view, this, false); addView(mTitleView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); addView(mIndicatorView, mIndicatorView.getLayoutParams()); }
From source file:com.mifos.mifosxdroid.formwidgets.FormWidget.java
public FormWidget(Context context, String name) { layout = new LinearLayout(context); layout.setLayoutParams(defaultLayoutParams); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(4, 4, 4, 4);/*w w w. j a va 2s . c om*/ property = name; displayText = name.replace("", " "); displayText = toTitleCase(displayText); returnType = SCHEMA_KEY_TEXT; }
From source file:com.aniruddhc.xPlod.ui.widgets.ScrollableTabView.java
public ScrollableTabView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); mContainer.setLayoutParams(params);/*from w ww.ja v a 2 s . c om*/ mContainer.setOrientation(LinearLayout.HORIZONTAL); this.addView(mContainer); }
From source file:com.github.preferencefragment.preference.LaunchingPreferences.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//from ww w . j a v a 2 s. com * These preferences have defaults, so before using them go apply those * defaults. This will only execute once -- when the defaults are applied * a boolean preference is set so they will not be applied again. */ PreferenceManager.setDefaultValues(this, R.xml.advanced_preferences, false); // Simple layout LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); // Create a simple button that will launch the preferences Button launchPreferences = new Button(this); launchPreferences.setText(getString(R.string.launch_preference_activity)); launchPreferences.setOnClickListener(this); layout.addView(launchPreferences, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mCounterText = new TextView(this); layout.addView(mCounterText, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); updateCounterText(); }
From source file:com.example.android.supportv7.util.DiffUtilActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = new LinearLayout(this); RecyclerView rv = new RecyclerView(this); Button shuffle = new Button(this); shuffle.setText("Shuffle"); ll.addView(shuffle);/*from www. ja v a2 s.c o m*/ ll.addView(rv); rv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rv.setLayoutManager(new LinearLayoutManager(this)); List<String> cheeseList = createRandomCheeseList(Collections.<String>emptyList(), 50); final SimpleStringAdapter adapter = new SimpleStringAdapter(this, cheeseList.toArray(new String[cheeseList.size()])); rv.setAdapter(adapter); final AtomicBoolean refreshingList = new AtomicBoolean(false); shuffle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (refreshingList.getAndSet(true)) { // already refreshing, do not allow modifications return; } //noinspection unchecked new AsyncTask<List<String>, Void, Pair<List<String>, DiffUtil.DiffResult>>() { @Override protected Pair<List<String>, DiffUtil.DiffResult> doInBackground(List<String>... lists) { List<String> oldList = lists[0]; List<String> newList = createRandomCheeseList(oldList, 5); DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MyCallback(oldList, newList)); //noinspection unchecked return new Pair(newList, diffResult); } @Override protected void onPostExecute(Pair<List<String>, DiffUtil.DiffResult> resultPair) { refreshingList.set(false); adapter.setValues(resultPair.first); resultPair.second.dispatchUpdatesTo(adapter); Toast.makeText(DiffUtilActivity.this, "new list size " + resultPair.first.size(), Toast.LENGTH_SHORT).show(); } }.execute(adapter.getValues()); } }); setContentView(ll); }
From source file:com.andrew.apolloMod.ui.widgets.ScrollableTabView.java
public ScrollableTabView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); // super(context, attrs, defStyle); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); mContainer.setLayoutParams(params);//from www . j a v a 2 s. com mContainer.setOrientation(LinearLayout.HORIZONTAL); this.addView(mContainer); }
From source file:com.alibaba.akita.samples.TestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }/* w w w . ja v a 2s . c om*/ TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); return layout; }
From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java
/** * // w w w. j a v a2 s. com * @param activity * @param autoclose - if the alert should close when connection is established * */ public static void show(Context activity, boolean autoclose, Intent after_connection_intent) { LinearLayout lin = new LinearLayout(activity); lin.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(activity); TextView details_text_view = new TextView(activity); LinearLayout lin_in_scrollview = new LinearLayout(activity); lin_in_scrollview.setOrientation(LinearLayout.VERTICAL); sv.addView(lin_in_scrollview); lin_in_scrollview.addView(details_text_view); details_text_view.setText("no text"); ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal); progress.setMax(img_lst.length); lin.addView(progress); lin.addView(sv); new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin) .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show(); class AlertDialogUpdater implements Runnable { private Handler h = new Handler(); private TextView myTextView; private ProgressBar myProgress; public AlertDialogUpdater(TextView ab, ProgressBar progress) { myTextView = ab; myProgress = progress; } public void run() { for (int i = 0; i < img_lst.length; i++) { class MsgUpdater implements Runnable { private int i; public MsgUpdater(int i) { this.i = i; } public void run() { myProgress.setProgress(i + 1); if (i != img_lst.length - 1) myTextView.setText("Downloading " + img_lst[i] + ".png"); else myTextView.setText("Ready - please restart DUBwise to apply changes!"); } } h.post(new MsgUpdater(i)); try { URLConnection ucon = new URL(url_lst[i]).openConnection(); BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) baf.append((byte) current); File path = new File( Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard"); path.mkdirs(); FileOutputStream fos = new FileOutputStream( new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png")); fos.write(baf.toByteArray()); fos.close(); } catch (Exception e) { } try { Thread.sleep(199); } catch (InterruptedException e) { } } } } new Thread(new AlertDialogUpdater(details_text_view, progress)).start(); }
From source file:com.gandulf.guilib.view.adapter.MultiFragmentPagerAdapter.java
@Override public Object instantiateItem(View container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }/*from ww w .j a v a2 s .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:com.manning.androidhacks.hack004.preference.AboutDialog.java
@Override protected View onCreateDialogView() { LinearLayout layout = new LinearLayout(mContext); layout.setOrientation(LinearLayout.VERTICAL); TextView splashText = new TextView(mContext); String fmt = "Version %s<br />" + "<a href=\"http://manning.com/sessa\">MoreInfo</a>"; try {//from w ww . j a v a 2 s . co m String pkg = mContext.getPackageName(); mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } if (mVersionNumber != null) { String aboutMsg = String.format(fmt, mVersionNumber); splashText.setText(Html.fromHtml(aboutMsg)); splashText.setMovementMethod(LinkMovementMethod.getInstance()); } layout.addView(splashText); return layout; }