List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:hongik.android.project.best.StoreReviewActivity.java
public void drawTable() throws Exception { String query = "func=morereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();//from www . ja v a 2 s .c o m conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) { return; } String storeName = jsonResult.getString("sname"); ((TextViewPlus) findViewById(R.id.storereview_storename)).setText(storeName); JSONArray review = null; if (!jsonResult.isNull("review")) { review = jsonResult.getJSONArray("review"); } //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); for (int i = 0; i < review.length(); i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); }
From source file:cc.metapro.openct.myclass.TableFragment.java
private void addSeqViews() { final int DailyClasses = Integer .parseInt(PrefHelper.getString(getContext(), R.string.pref_daily_class_count, "12")); for (int i = 1; i <= DailyClasses; i++) { TextView textView = new TextView(getContext()); textView.setText(i + ""); textView.setGravity(Gravity.CENTER); textView.setMinHeight(Constants.CLASS_BASE_HEIGHT * Constants.CLASS_LENGTH); textView.setMaxHeight(Constants.CLASS_BASE_HEIGHT * Constants.CLASS_LENGTH); textView.setTextSize(10);// w ww.j a v a2 s . c o m mSeq.addView(textView); } }
From source file:be.ac.ucl.lfsab1509.llncampus.ExternalAppUtility.java
/** * Start the Google Maps application and navigate the user to the specified location. * /* w ww . j a v a 2 s . c o m*/ * @param lat * Destination latitude. * @param lon * Destination longitude. * @param c * Current context. */ public static void startNavigation(float lat, float lon, Context c) { try { Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + lat + "," + lon + "&dirflg=w")); intent.setComponent( new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); c.startActivity(intent); } catch (ActivityNotFoundException e) { // If we don't have Google Maps Log.e("ExternalAppUtility", c.getString(R.string.no_google_maps)); Toast t = Toast.makeText(LLNCampus.getContext().getApplicationContext(), R.string.no_google_maps, Toast.LENGTH_LONG); t.setGravity(Gravity.CENTER, 0, 0); t.show(); } }
From source file:ca.farrelltonsolar.classic.DayLogCalendar.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { theView = inflater.inflate(R.layout.day_log_calendar, container, false); Bundle args = getArguments();/* w w w . ja va 2 s. co m*/ int monthOffset = args != null ? args.getInt(ARG_MONTH) : 0; month = DateTime.now().minusMonths(monthOffset).withTimeAtStartOfDay().withDayOfMonth(1); adapter = new CalendarAdapter(this.getActivity(), month); GridView gridview = (GridView) theView.findViewById(R.id.gridview); gridview.setAdapter(adapter); gridview.setVelocityScale(5); TextView title = (TextView) theView.findViewById(R.id.title); title.setText(month.toString("MMMM yyyy")); View linearLayout = theView.findViewById(R.id.headerlayout); DateTime days = month; for (int i = 0; i < 7; i++) { int d = ((i + 6) % 7) + 1; days = days.withDayOfWeek(d); TextView aDay = new TextView(theView.getContext()); aDay.setText(DateTimeFormat.forPattern("E").print(days)); aDay.setGravity(Gravity.CENTER); aDay.setTextColor(Color.BLACK); aDay.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); ((LinearLayout) linearLayout).addView(aDay); } return theView; }
From source file:com.auth0.android.lock.views.PasswordlessFormLayout.java
private void init() { setOrientation(VERTICAL);//from www. j a v a 2 s . c om setGravity(Gravity.CENTER); boolean showSocial = !lockWidget.getConfiguration().getSocialConnections().isEmpty(); boolean showPasswordless = lockWidget.getConfiguration().getPasswordlessConnection() != null; if (showSocial) { addSocialLayout(showPasswordless); } if (showPasswordless) { if (showSocial) { addSeparator(); } addPasswordlessRequestCodeLayout(); } final int verticalPadding = getResources() .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field); setPadding(0, verticalPadding, 0, verticalPadding); }
From source file:com.example.android.MainActivity.java
/**Display JSON data in table format on the user interface of android app * by clicking on the button 'Start'*/ @Override/*from w ww . ja va 2 s . co m*/ protected void onCreate(Bundle savedInstanceState) { /** * Declares TextView, Button and Tablelayout to retrieve the widgets * from User Interface. Insert the TableRow into Table and set the * gravity, font size and id of table rows and columns. * * Due to great amount of JSON data, 'for' loop method is used to insert * the new rows and columns in the table. In each loop, each of rows and * columns are set to has its own unique id. This purpose of doing this * is to allows the user to read and write the text of specific rows and * columns easily. */ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progress = new ProgressDialog(this); StartDisplay = (Button) findViewById(R.id.btnDisplay); profile = (TableLayout) findViewById(R.id.tableLayout1); profile.setStretchAllColumns(true); profile.bringToFront(); for (int i = 1; i < 11; i++) { TableRow tr = new TableRow(this); TextView c1 = new TextView(this); TextView c2 = new TextView(this); c1.setId(i * 10 + 1); c1.setTextSize(12); c1.setGravity(Gravity.CENTER); c2.setId(i * 10 + 2); c2.setTextSize(12); c2.setGravity(Gravity.CENTER); tr.addView(c1); tr.addView(c2); tr.setGravity(Gravity.CENTER_HORIZONTAL); profile.addView(tr); } /** * onClick: Executes the DownloadWebPageTask once OnClick event occurs. * When user click on the "Start" button, * 1)the JSON data will be read from URL * 2)Progress bar will be shown till all data is read and displayed in * table form. Once it reaches 100%, it will be dismissed. * * Progress Bar: The message of the progress bar is obtained from strings.xml. * New thread is created to handle the action of the progress bar. */ StartDisplay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final String TAG = "MyActivity"; progress.setMessage(getResources().getString(R.string.ProgressBar_message)); progress.setCancelable(true); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setProgress(0); progress.setMax(100); progress.show(); new Thread(new Runnable() { public void run() { while (ProgressBarStatus < 100) { try { Thread.sleep(500); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progressBarbHandler.post(new Runnable() { public void run() { progress.setProgress(ProgressBarStatus); } }); } if (ProgressBarStatus >= 100) { try { Thread.sleep(1000); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progress.dismiss(); } } }).start(); DownloadWebPageTask task = new DownloadWebPageTask(); task.execute("http://private-ae335-pgserverapi.apiary.io/user/profile/234"); StartDisplay.setClickable(false); } }); }
From source file:com.example.clienttest.AbstractGreenhouseActivity.java
protected void displayNetworkError() { Toast toast = Toast.makeText(this, "A problem occurred with the network connection while attempting to communicate with Greenhouse.", Toast.LENGTH_LONG);/*w w w. j a va 2s. com*/ toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:at.wada811.android.dialogfragments.sample.dialogfragmentcallbackprovider.DialogFragmentCallbackProviderFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override// ww w . j av a 2s . c o m public View getView(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText("Use getChildFragmentManager()"); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } }; }
From source file:com.knurld.dropboxdemo.KnurldActivity.java
public void showInstructions(View view) { Activity parent = (Activity) context; View spinnerView = LayoutInflater.from(parent).inflate(R.layout.instructions_popup, null); TextView textView = (TextView) spinnerView.findViewById(R.id.phraseText); textView.setText("Press record to begin recording enrollment"); PopupWindow popupWindow = new PopupWindow(spinnerView, 500, 500); popupWindow.setFocusable(true);/*from w w w .j av a 2s .c om*/ popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0); final PopupWindow finalPopupWindow = popupWindow; new android.os.Handler().postDelayed(new Runnable() { public void run() { finalPopupWindow.dismiss(); } }, 3000); }
From source file:com.acious.android.paginationseekbar.internal.Marker.java
public Marker(Context context, AttributeSet attrs, int defStyleAttr, String maxValue) { super(context, attrs, defStyleAttr); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PaginationSeekBar, R.attr.paginationSeekBarStyle, R.style.DefaultSeekBar); int padding = (int) (PADDING_DP * displayMetrics.density) * 2; int textAppearanceId = a.getResourceId(R.styleable.PaginationSeekBar_psb_indicatorTextAppearance, R.style.DefaultIndicatorTextAppearance); mNumber = new TextView(context); //Add some padding to this textView so the bubble has some space to breath mNumber.setPadding(padding, 0, padding, 0); mNumber.setTextAppearance(context, textAppearanceId); mNumber.setGravity(Gravity.CENTER); mNumber.setText(maxValue);//from w w w . java 2 s .co m mNumber.setMaxLines(1); mNumber.setSingleLine(true); SeekBarCompat.setTextDirection(mNumber, TEXT_DIRECTION_LOCALE); mNumber.setVisibility(View.INVISIBLE); //add some padding for the elevation shadow not to be clipped //I'm sure there are better ways of doing this... setPadding(padding, padding, padding, padding); resetSizes(maxValue); mSeparation = (int) (SEPARATION_DP * displayMetrics.density); int thumbSize = (int) (ThumbDrawable.DEFAULT_SIZE_DP * displayMetrics.density); ColorStateList color = a.getColorStateList(R.styleable.PaginationSeekBar_psb_indicatorColor); mMarkerDrawable = new MarkerDrawable(color, thumbSize); mMarkerDrawable.setCallback(this); mMarkerDrawable.setMarkerListener(this); mMarkerDrawable.setExternalOffset(padding); //Elevation for anroid 5+ float elevation = a.getDimension(R.styleable.PaginationSeekBar_psb_indicatorElevation, ELEVATION_DP * displayMetrics.density); ViewCompat.setElevation(this, elevation); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SeekBarCompat.setOutlineProvider(this, mMarkerDrawable); } a.recycle(); }