List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, final Uri uri, final LocalGeoJsonLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from w w w. ja va2 s . c om final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); if (!bCreate) { //TODO: style for drawing } new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (bCreate) { create(map, input.getText().toString(), uri); } else { layer.setName(input.getText().toString()); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:com.foxconn.remote.control.widget.CustomPagerIndicator.java
public CustomPagerIndicator(Context context, AttributeSet attrs) { super(context, attrs); // ?Bar?//from w ww . j a va2s .c o m setHorizontalScrollBarEnabled(false); mInflater = LayoutInflater.from(context); mTabLayout = new LinearLayout(getContext()); addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
From source file:com.greencode.enticement_android.UI.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);/*from w w w. j a v a2s . co m*/ mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new LinearLayout(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:com.clov4r.moboplayer.android.nil.codec.activity.MoboThumbnailTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); imageView = new ImageView(this); SubtitleJni h = new SubtitleJni(); String libpath = getFilesDir().getParent() + "/lib/"; String libname = "libffmpeg.so";// libffmpeg_armv7_neon.so h.loadFFmpegLibs(libpath, libname);//from w w w . java 2 s. c o m Button button = new Button(this); layout.addView(button); layout.addView(imageView); button.setText(""); setContentView(layout); button.setOnClickListener(mOnClickListener); }
From source file:br.org.funcate.dynamicforms.views.GTimeView.java
/** * @param fragment the fragment.// w w w . j av a2 s. com * @param attrs attributes. * @param parentView parent * @param label label * @param value value * @param constraintDescription constraints * @param readonly if <code>false</code>, the item is disabled for editing. */ public GTimeView(final Fragment fragment, AttributeSet attrs, LinearLayout parentView, String label, String value, String constraintDescription, boolean readonly) { super(fragment.getActivity(), attrs); final Context context = fragment.getActivity(); LinearLayout textLayout = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(context.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); button = new Button(context); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); final SimpleDateFormat timeFormatter = TimeUtilities.INSTANCE.TIMEONLY_FORMATTER; if (value == null || value.length() == 0) { String dateStr = timeFormatter.format(new Date()); button.setText(dateStr); } else { button.setText(value); } button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String dateStr = button.getText().toString(); Date date = null; try { date = timeFormatter.parse(dateStr); } catch (ParseException e) { //GPLog.error(this, null, e); Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); // fallback on current date date = new Date(); } final Calendar c = Calendar.getInstance(); c.setTime(date); int hourOfDay = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); FormTimePickerFragment newFragment = new FormTimePickerFragment(); newFragment.setAttributes(hourOfDay, minute, true, button); //newFragment.show(fragment.getFragmentManager(), "timePicker"); } }); button.setEnabled(!readonly); textLayout.addView(button); }
From source file:br.org.funcate.dynamicforms.views.GDateView.java
/** * @param fragment the fragment to use. * @param attrs attributes.//from w w w . j a va 2s . c o m * @param parentView parent * @param label label * @param value value * @param constraintDescription constraints * @param readonly if <code>false</code>, the item is disabled for editing. */ public GDateView(final Fragment fragment, AttributeSet attrs, LinearLayout parentView, String label, String value, String constraintDescription, boolean readonly) { super(fragment.getActivity(), attrs); final Context context = fragment.getActivity(); LinearLayout textLayout = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(context.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); button = new Button(context); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); final SimpleDateFormat dateFormatter = TimeUtilities.INSTANCE.DATEONLY_FORMATTER; if (value == null || value.length() == 0) { String dateStr = dateFormatter.format(new Date()); button.setText(dateStr); } else { button.setText(value); } button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String dateStr = button.getText().toString(); Date date = null; try { date = dateFormatter.parse(dateStr); } catch (ParseException e) { //GPLog.error(this, null, e); Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); date = new Date(); } final Calendar c = Calendar.getInstance(); c.setTime(date); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); FormDatePickerFragment newFragment = new FormDatePickerFragment(); newFragment.setAttributes(year, month, day, button); newFragment.show(fragment.getFragmentManager(), "datePicker"); } }); button.setEnabled(!readonly); textLayout.addView(button); }
From source file:co.ldln.android.ObjectReadFragment.java
@Override public void onReadSchemaResult(Schema schema) { mSchema = schema;// w ww .j a va 2s .c om HashMap<String, String> keyValueMap = mSyncableObject.getKeyValueMap(); for (SchemaField schemaField : mSchema.getFields(mActivity)) { String label = schemaField.getLabel(); String value = keyValueMap.get(label); String type = schemaField.getType(); // Create a linear layout to hold the field LinearLayout ll = new LinearLayout(mActivity); LayoutParams llParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); ll.setOrientation(LinearLayout.HORIZONTAL); // TODO: different UI for different field types // Default to TextView TextView labelTv = new TextView(mActivity); LayoutParams labelTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); labelTv.setLayoutParams(labelTvParams); labelTv.setText(label); labelTv.setPadding(0, 0, 20, 0); labelTv.setTypeface(Typeface.DEFAULT_BOLD); ll.addView(labelTv); TextView valueTv = new TextView(mActivity); LayoutParams valueTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); valueTv.setLayoutParams(valueTvParams); valueTv.setText(value); ll.addView(valueTv); mFormHolder.addView(ll); } }
From source file:com.cerema.cloud2.ui.dialog.CredentialsDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Create field for username mUsernameET = new EditText(getActivity()); mUsernameET.setHint(getActivity().getText(R.string.auth_username)); // Create field for password mPasswordET = new EditText(getActivity()); mPasswordET.setHint(getActivity().getText(R.string.auth_password)); mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // Prepare LinearLayout for dialog LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(mUsernameET);//from w w w.j av a 2 s . com ll.addView(mPasswordET); ll.requestFocus(); setRetainInstance(true); Builder authDialog = new AlertDialog.Builder(getActivity()) .setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll) .setCancelable(false).setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this); Dialog d = authDialog.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; }
From source file:com.google.unity.AdMobPlugin.java
/** * Creates an {@link AdView} to old ads. * * @param activity The activity to place the {@code AdView}. * @param publisherId Your publisher ID from the AdMob or DFP console * @param adSizeString A string ad size constant representing the desired ad size. * @param positionAtTop True to position the ad at the top of the screen. False to position * the ad at the bottom of the screen. *//*from w w w. j a v a 2 s. co m*/ public static void createBannerView(final Activity activity, final String publisherId, final String adSizeString, final boolean positionAtTop) { Log.d(LOGTAG, "called createBannerView in Java code"); final AdMobPlugin plugin = AdMobPlugin.instance(); plugin.activity = activity; activity.runOnUiThread(new Runnable() { @Override public void run() { AdSize adSize = AdMobPlugin.adSizeFromSize(adSizeString); if (adSize == null) { Log.e(AdMobPlugin.LOGTAG, "AdSize is null. Did you use an AdSize constant?"); return; } plugin.adView = new AdView(activity, adSize, publisherId); plugin.adView.setAdListener(plugin); LinearLayout layout = new LinearLayout(activity); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = positionAtTop ? Gravity.TOP : Gravity.BOTTOM; activity.addContentView(layout, layoutParams); LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); layout.addView(plugin.adView, adParams); } }); }
From source file:com.everyplay.android.everyplayrecord.EveryplayRecordActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create a GLSurfaceView instance and set it // as the ContentView for this Activity mGLView = new EveryplayRecordSurfaceView(this); setContentView(mGLView);//from w w w. jav a 2s . co m buttons = new LinearLayout(this); buttons.setOrientation(LinearLayout.VERTICAL); if (!USE_EVERYPLAY_AUDIO_BOARD) { addButton("Everyplay", "everyplay"); addButton("Start recording", "rec"); Button playLastRecording = addButton("Play last recording", "play_last_recording"); playLastRecording.setVisibility(View.GONE); addButton("Test video playback", "test_video_playback"); addButton("Show sharing modal", "sharing_modal"); Button hudRecord = addButton("HUD record off", "hud_record"); hudRecord.setVisibility(View.GONE); stream1 = new EveryplayRecordAudioGenerator(5); stream1.play(); streamActive = stream1; } else { addButton("Play song #1", "play1_a"); addButton("Unload song #1", "unload1_a"); addButton("Pause song", "pause_a"); addButton("Resume song", "resume_a"); addButton("Rewind song", "rewind_a"); addButton("Stop song", "stop_a"); this.addContentView(buttons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); buttons = new LinearLayout(this); buttons.setOrientation(LinearLayout.VERTICAL); buttons.setX(400); addButton("Play song #2", "play2_a"); addButton("Unload song #2", "unload2_a"); addButton("Effect #1", "effect1_a"); addButton("Effect #2", "effect2_a"); addButton("Start recording", "rec"); addButton("Play last recording", "play_last_recording"); soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); sound_pew = soundPool.load(this, R.raw.pew, 1); sound_pow = soundPool.load(this, R.raw.pow, 1); } this.addContentView(buttons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); init(); }