List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
/** * Function that is called when you press the add tag * //from w w w .ja va 2s . c om * Creates a alert dialog that gives the user the option * of adding a previously added tag or entering a new tag name * * @param view */ public void addTagButton(View view) { final EditText enterTag = new EditText(this); final Spinner tagSpinner = new Spinner(this); //Linear layout that holds enterTag and tagSpinner views LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); tagSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View arg1, int position, long id) { enterTag.setText(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); enterTag.setHint("Enter tag"); AlertDialog.Builder alert = new AlertDialog.Builder(this); //get all the tags currently added to claims in application claimlist ArrayList<Tag> tags = ClaimListController.getTagList(); String t[] = new String[tags.size()]; for (int i = 0; i < tags.size(); i++) { t[i] = tags.get(i).getName(); } //create a arrayadaptor for displaying the tagSpinner view, and set it ArrayAdapter<String> tagA = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, t); tagSpinner.setAdapter(tagA); //add views to linear layout and set the Linear layout view as the alert dialog view ll.addView(tagSpinner); ll.addView(enterTag); alert.setView(ll); alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Tag tag = new Tag(enterTag.getText().toString()); if (theClaim.getTagList().getTag(enterTag.getText().toString()) != null) { return; } ClaimListController.addTag(theClaim, tag); tagAdaptor.notifyDataSetChanged(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); }
From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java
private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) { ViewGroup groupView;//from ww w. j av a 2s . c o m if (view != null && view instanceof ViewGroup) { groupView = (ViewGroup) view; // If there are more children in the recycled view we remove the extra ones. if (groupView.getChildAt(0) instanceof LinearLayout) { LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0); if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) { groupViewContent.removeViews(rowInfo.group.getRowCount(), groupViewContent.getChildCount() - rowInfo.group.getRowCount()); } } // Use the defined callbacks if the user has chosen to by implementing a // CardsCollectionViewCallbacks. } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) { groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks) .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent); // This should never happened but if it does we'll display an EmptyView. } else { LOGE(TAG, "Tried to create a group view but the callback is not an instance of " + "GroupCollectionViewCallbacks"); return new EmptyView(getContext()); } LinearLayout groupViewContent; if (groupView.getChildAt(0) instanceof LinearLayout) { groupViewContent = (LinearLayout) groupView.getChildAt(0); } else { groupViewContent = new LinearLayout(getContext()); groupViewContent.setOrientation(LinearLayout.VERTICAL); LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); groupViewContent.setLayoutParams(LLParams); groupView.addView(groupViewContent); } disableCustomGroupView(); for (int i = 0; i < rowInfo.group.getRowCount(); i++) { View itemView; try { itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent); } catch (Exception e) { // Recycling failed (maybe the items were not compatible) so we start again without // recycling. itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent); } if (itemView != groupViewContent.getChildAt(i)) { if (groupViewContent.getChildCount() > i) { groupViewContent.removeViewAt(i); } groupViewContent.addView(itemView, i); } } enableCustomGroupView(); return groupView; }
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
public void verifyAccount() { final AlertDialog builder = new AlertDialog.Builder(this, R.style.InvitationDialog) .setPositiveButton("Done", null).setNegativeButton("Cancel", null).create(); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText emailBox = new EditText(this); emailBox.setTextColor(getResources().getColor(R.color.icons)); emailBox.setHintTextColor(getResources().getColor(R.color.icons)); emailBox.setHint("Email"); layout.addView(emailBox);/*from ww w.j av a 2s . c o m*/ final EditText codeBox = new EditText(this); codeBox.setTextColor(getResources().getColor(R.color.icons)); codeBox.setHintTextColor(getResources().getColor(R.color.icons)); codeBox.setHint("Code"); layout.addView(codeBox); builder.setView(layout); // final EditText etNickName = new EditText(this); // etNickName.setTextColor(Color.parseColor("#FFFFFF")); // builder.setView(etNickName); builder.setTitle("Verify registration"); builder.setMessage("Enter emailId and code to activate account"); builder.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button btnAccept = builder.getButton(AlertDialog.BUTTON_POSITIVE); btnAccept.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (emailBox.getText().toString().isEmpty() && codeBox.getText().toString().isEmpty()) { Toast.makeText(getApplicationContext(), "Fields cannot be empty", Toast.LENGTH_SHORT) .show(); } else { verifyApi(emailBox.getText().toString(), codeBox.getText().toString()); builder.dismiss(); } } }); final Button btnDecline = builder.getButton(DialogInterface.BUTTON_NEGATIVE); btnDecline.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { builder.dismiss(); } }); } }); builder.show(); }
From source file:com.citrus.sample.UIActivity.java
private void promptAutoLoadSubscription() { final AlertDialog.Builder alert = new AlertDialog.Builder(UIActivity.this); String message = null;// w w w.j a v a 2 s . co m String positiveButtonText = "Yes"; LinearLayout linearLayout = new LinearLayout(UIActivity.this); linearLayout.setOrientation(LinearLayout.VERTICAL); alert.setTitle("Enable Auto-Load?"); alert.setMessage(getString(R.string.auto_load_message)); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction() .setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right) .replace(R.id.container, AutoLoadFragment.newInstance()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); alert.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showCashoutPrompt() { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); String message = "Please enter account details."; String positiveButtonText = "Withdraw"; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelAmount = new TextView(getActivity()); final EditText editAmount = new EditText(getActivity()); final TextView labelAccountNo = new TextView(getActivity()); final EditText editAccountNo = new EditText(getActivity()); editAccountNo.setSingleLine(true);//w ww.jav a2 s .c o m final TextView labelAccountHolderName = new TextView(getActivity()); final EditText editAccountHolderName = new EditText(getActivity()); editAccountHolderName.setSingleLine(true); final TextView labelIfscCode = new TextView(getActivity()); final EditText editIfscCode = new EditText(getActivity()); editIfscCode.setSingleLine(true); labelAmount.setText("Withdrawal Amount"); labelAccountNo.setText("Account Number"); labelAccountHolderName.setText("Account Holder Name"); labelIfscCode.setText("IFSC Code"); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelAmount.setLayoutParams(layoutParams); labelAccountNo.setLayoutParams(layoutParams); labelAccountHolderName.setLayoutParams(layoutParams); labelIfscCode.setLayoutParams(layoutParams); editAmount.setLayoutParams(layoutParams); editAccountNo.setLayoutParams(layoutParams); editAccountHolderName.setLayoutParams(layoutParams); editIfscCode.setLayoutParams(layoutParams); linearLayout.addView(labelAmount); linearLayout.addView(editAmount); linearLayout.addView(labelAccountNo); linearLayout.addView(editAccountNo); linearLayout.addView(labelAccountHolderName); linearLayout.addView(editAccountHolderName); linearLayout.addView(labelIfscCode); linearLayout.addView(editIfscCode); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); alert.setTitle("Withdraw Money To Your Account"); alert.setMessage(message); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String amount = editAmount.getText().toString(); String accontNo = editAccountNo.getText().toString(); String accountHolderName = editAccountHolderName.getText().toString(); String ifsc = editIfscCode.getText().toString(); CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc); mListener.onCashoutSelected(cashoutInfo); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editAmount.requestFocus(); alert.show(); }
From source file:android.support.designox.widget.TextInputLayout.java
private void addIndicator(TextView indicator, int index) { if (mIndicatorArea == null) { mIndicatorArea = new LinearLayout(getContext()); mIndicatorArea.setOrientation(LinearLayout.HORIZONTAL); addView(mIndicatorArea, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // Add a flexible spacer in the middle so that the left/right views stay pinned final Space spacer = new Space(getContext()); final LinearLayout.LayoutParams spacerLp = new LinearLayout.LayoutParams(0, 0, 1f); mIndicatorArea.addView(spacer, spacerLp); if (mEditText != null) { adjustIndicatorPadding();/* w w w . ja va 2s . c om*/ } } mIndicatorArea.setVisibility(View.VISIBLE); mIndicatorArea.addView(indicator, index); mIndicatorsAdded++; }
From source file:com.microsoft.windowsazure.mobileservices.authentication.LoginManager.java
/** * Creates the UI for the interactive authentication process * * @param startUrl The initial URL for the authentication process * @param endUrl The final URL for the authentication process * @param context The context used to create the authentication dialog * @param callback Callback to invoke when the authentication process finishes *//*w ww .j a va 2 s . c o m*/ private void showLoginUIInternal(final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); wv.getSettings().setJavaScriptEnabled(true); DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int webViewHeight = displaymetrics.heightPixels - 100; wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight)); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
From source file:com.facebook.LikeView.java
private void initialize(Context context) { edgePadding = getResources().getDimensionPixelSize(R.dimen.com_facebook_likeview_edge_padding); internalPadding = getResources().getDimensionPixelSize(R.dimen.com_facebook_likeview_internal_padding); if (foregroundColor == NO_FOREGROUND_COLOR) { foregroundColor = getResources().getColor(R.color.com_facebook_likeview_text_color); }//from w w w.j a v a2 s. co m setBackgroundColor(Color.TRANSPARENT); containerView = new LinearLayout(context); LayoutParams containerViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); containerView.setLayoutParams(containerViewLayoutParams); initializeLikeButton(context); initializeSocialSentenceView(context); initializeLikeCountView(context); containerView.addView(likeButton); containerView.addView(socialSentenceView); containerView.addView(likeBoxCountView); addView(containerView); setObjectIdAndTypeForced(this.objectId, this.objectType); updateLikeStateAndLayout(); }
From source file:com.actionbarsherlock.internal.view.menu.MenuItemImpl.java
public MenuItem setActionView(int resId) { final Context context = mMenu.getContext(); final LayoutInflater inflater = LayoutInflater.from(context); setActionView(inflater.inflate(resId, new LinearLayout(context), false)); return this; }
From source file:com.guipenedo.pokeradar.activities.MapsActivity.java
/** * Manipulates the map once available.//from w ww . j a v a 2 s. c om * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); mMap.getUiSettings().setMyLocationButtonEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.setOnMapLongClickListener(this); mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { onConnected(null); update(); return true; } }); mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker m) { PMarker marker = pokemonMarkers.get(m.getId()); if (marker == null || marker.type != PMarker.MarkerType.GYM) return; Intent gymIntent = new Intent(MapsActivity.this, GymDetailsActivity.class); gymIntent.putExtra("gymDetails", (PGym) marker); startActivity(gymIntent); } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker arg0) { return null; } @Override public View getInfoContents(final Marker m) { Context mContext = MapsActivity.this; LinearLayout info = new LinearLayout(mContext); info.setOrientation(LinearLayout.VERTICAL); TextView title = new TextView(mContext); title.setText(m.getTitle()); title.setTypeface(null, Typeface.BOLD); title.setGravity(Gravity.CENTER); info.addView(title); final PMarker marker = pokemonMarkers.get(m.getId()); long timestamp = -1; if (marker != null) { if (marker.type == PMarker.MarkerType.CENTER) { TextView littleNotice = new TextView(mContext); littleNotice.setText(R.string.scan_center_infowindow); littleNotice.setGravity(Gravity.CENTER); info.addView(littleNotice); } else if (marker.type == PMarker.MarkerType.LUREDPOKESTOP) { PPokestop pokestopMarker = (PPokestop) marker; timestamp = pokestopMarker.getTimestamp(); TextView remainingTime = new TextView(mContext); String text = String.format(getString(R.string.lured_remaining), Utils.countdownFromMillis( mContext, pokestopMarker.getTimestamp() - System.currentTimeMillis())); remainingTime.setText(text); remainingTime.setGravity(Gravity.CENTER); info.addView(remainingTime); TextView expireTime = new TextView(mContext); expireTime.setText(Utils.timeFromMillis(pokestopMarker.getTimestamp())); expireTime.setGravity(Gravity.CENTER); info.addView(expireTime); } else if (marker.type == PMarker.MarkerType.GYM) { PGym gymMarker = (PGym) marker; Team team = Team.fromTeamColor(gymMarker.getTeam()); TextView teamName = new TextView(mContext); teamName.setText(team.getName()); teamName.setTextColor(team.getColor()); teamName.setGravity(Gravity.CENTER); info.addView(teamName); TextView prestige = new TextView(mContext); prestige.setText(String.format(getString(R.string.gym_points), gymMarker.getPoints())); prestige.setGravity(Gravity.CENTER); info.addView(prestige); TextView clickDetails = new TextView(mContext); clickDetails.setText(R.string.gym_details); clickDetails.setTypeface(null, Typeface.BOLD); clickDetails.setGravity(Gravity.CENTER); info.addView(clickDetails); } else if (marker.type == PMarker.MarkerType.POKEMON) { PPokemon pokemonMarker = (PPokemon) marker; timestamp = pokemonMarker.getTimestamp(); final TextView remainingTime = new TextView(mContext); remainingTime.setText( String.format(getString(R.string.pokemon_despawns_time), Utils.countdownFromMillis( mContext, pokemonMarker.getTimestamp() - System.currentTimeMillis()))); remainingTime.setGravity(Gravity.CENTER); info.addView(remainingTime); TextView expireTime = new TextView(mContext); expireTime.setText(Utils.timeFromMillis(pokemonMarker.getTimestamp())); expireTime.setGravity(Gravity.CENTER); info.addView(expireTime); } if (timestamp != -1 && (countdownMarker == null || !countdownMarker.equals(m.getId()))) { countdownMarker = m.getId(); new CountDownTimer(timestamp - System.currentTimeMillis(), 1000) { public void onTick(long millisUntilFinished) { if (markers.contains(m) && m.isInfoWindowShown()) m.showInfoWindow(); else cancel(); } @Override public void onFinish() { countdownMarker = null; } }.start(); } } return info; } }); update(); }