List of usage examples for android.text InputType TYPE_CLASS_NUMBER
int TYPE_CLASS_NUMBER
To view the source code for android.text InputType TYPE_CLASS_NUMBER.
Click Source Link
From source file:com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain.java
private void updateItems() { mServingSizeUpdated.setText("1"); LinearLayout changeServing = (LinearLayout) findViewById(R.id.changeServing); changeServing.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j a va 2s .c o m public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(SaveSearchAddItemActivityMain.this); alert.setTitle("Update Serving Size: "); alert.setMessage("Servings Consumed"); final EditText input = new EditText(SaveSearchAddItemActivityMain.this); input.setText(mServingg.getText().toString()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); input.selectAll(); input.setGravity(Gravity.CENTER_HORIZONTAL); alert.setView(input, 64, 0, 64, 0); alert.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double values = Double.valueOf(input.getText().toString()); mServingg.setText(df.format(values)); mServingSizeUpdated.setText(df.format(values)); mCalUpdate.setText(dfW.format(Double.valueOf(mCalories) * values)); mCalorieProgress = Double.valueOf(mCalories) * values; mFattieUpdate.setText(df.format(Double.valueOf(mFat) * values)); mFatProgress = Double.valueOf(mFat) * values; mSaturatedFatUpdate.setText(df.format(Double.valueOf(mSaturatedFat) * values)); mCholesterolUpdate.setText(df.format(Double.valueOf(mCholesterol) * values)); mSodiumUpdate.setText(df.format(Double.valueOf(mSodium) * values)); mCarbUpdate.setText(df.format(Double.valueOf(mCarbohydrates) * values)); mCarbProgress = Double.valueOf(mCarbohydrates) * values; mFiberUpdate.setText(df.format(Double.valueOf(mFiber) * values)); mSugarUpdate.setText(df.format(Double.valueOf(mSugar) * values)); mProUpdate.setText(df.format(Double.valueOf(mProtein) * values)); mProteinProgress = Double.valueOf(mProtein) * values; mVitAUpdate.setText(df.format(Double.valueOf(mVitA) * values)); mVitCUpdate.setText(df.format(Double.valueOf(mVitC) * values)); mCalciumUpdate.setText(df.format(Double.valueOf(mCalcium) * values)); mIronUpdate.setText(df.format(Double.valueOf(mIron) * values)); progressBars(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setCancelable(false); alert.show(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); } }); }
From source file:de.qspool.clementineremote.ui.ConnectActivity.java
/** * Show the user the dialog to enter the auth code *//*from ww w. j av a 2s. c o m*/ void showAuthCodePromt() { new MaterialDialog.Builder(this).title(R.string.input_auth_code).inputType(InputType.TYPE_CLASS_NUMBER) .input("", "", false, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { try { mAuthCode = Integer.parseInt(input.toString()); dialog.dismiss(); connect(); } catch (NumberFormatException e) { Toast.makeText(ConnectActivity.this, R.string.invalid_code, Toast.LENGTH_SHORT).show(); } } }).show(); }
From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java
private void setTabChange(int tab) { mInputMethodManager.hideSoftInputFromWindow(mNosunEditText.getWindowToken(), 0); mTabMode = tab;//from w w w . j a v a 2 s . c om switch (tab) { case TAB_FAVORITE: mLocationManager.removeUpdates(this); mLayoutFavorite.setVisibility(View.VISIBLE); mLayoutNosun.setVisibility(View.GONE); mLayoutBusstop.setVisibility(View.GONE); mLayoutLocation.setVisibility(View.GONE); mTabFavorite.setBackgroundColor(Color.parseColor("#7F7F72")); mTabNosun.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabBusstop.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabLocation.setBackgroundColor(Color.parseColor("#F7F7F0")); mTextFavorite.setTextColor(Color.parseColor("#FFFFFF")); mTextNosun.setTextColor(Color.parseColor("#7F7F72")); mTextBusstop.setTextColor(Color.parseColor("#7F7F72")); mTextSetting.setTextColor(Color.parseColor("#7F7F72")); mImageFavorite.setImageResource(R.drawable.ic_main_tab_favorite_pressed); mImageNosun.setImageResource(R.drawable.ic_main_tab_search_normal); mImageBusstop.setImageResource(R.drawable.ic_main_tab_stop_normal); mImageLocation.setImageResource(R.drawable.ic_main_tab_compass_normal); if (mBusanBusPrefrence.getIsFavoriteLocation()) setFavoriteTabChange(mBusanBusPrefrence.getFavoriteLocation()); else setFavoriteTabChange(FAVORITE_TAB_NOSUN); switch (mFavoriteMode) { case FAVORITE_TAB_NOSUN: favoriteBusStop(); favoriteNosun(); break; case FAVORITE_TAB_BUSSTOP: favoriteNosun(); favoriteBusStop(); break; } tracker.trackEvent("TabClicks", // Category "Favorite", // Action "", // Label 0); // Value break; case TAB_NOSUN: mLocationManager.removeUpdates(this); mLayoutFavorite.setVisibility(View.GONE); mLayoutNosun.setVisibility(View.VISIBLE); mLayoutBusstop.setVisibility(View.GONE); mLayoutLocation.setVisibility(View.GONE); mNosunEditText.setInputType(InputType.TYPE_CLASS_NUMBER); mTabFavorite.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabNosun.setBackgroundColor(Color.parseColor("#7F7F72")); mTabBusstop.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabLocation.setBackgroundColor(Color.parseColor("#F7F7F0")); mTextFavorite.setTextColor(Color.parseColor("#7F7F72")); mTextNosun.setTextColor(Color.parseColor("#FFFFFF")); mTextBusstop.setTextColor(Color.parseColor("#7F7F72")); mTextSetting.setTextColor(Color.parseColor("#7F7F72")); mImageFavorite.setImageResource(R.drawable.ic_main_tab_favorite_normal); mImageNosun.setImageResource(R.drawable.ic_main_tab_search_pressed); mImageBusstop.setImageResource(R.drawable.ic_main_tab_stop_normal); mImageLocation.setImageResource(R.drawable.ic_main_tab_compass_normal); tracker.trackEvent("TabClicks", // Category "LineSearch", // Action "", // Label 0); // Value break; case TAB_BUSSTOP: mLocationManager.removeUpdates(this); mLayoutFavorite.setVisibility(View.GONE); mLayoutNosun.setVisibility(View.GONE); mLayoutBusstop.setVisibility(View.VISIBLE); mLayoutLocation.setVisibility(View.GONE); mBusStopEditText.setInputType(InputType.TYPE_CLASS_TEXT); mTabFavorite.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabNosun.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabBusstop.setBackgroundColor(Color.parseColor("#7F7F72")); mTabLocation.setBackgroundColor(Color.parseColor("#F7F7F0")); mTextFavorite.setTextColor(Color.parseColor("#7F7F72")); mTextNosun.setTextColor(Color.parseColor("#7F7F72")); mTextBusstop.setTextColor(Color.parseColor("#FFFFFF")); mTextSetting.setTextColor(Color.parseColor("#7F7F72")); mImageFavorite.setImageResource(R.drawable.ic_main_tab_favorite_normal); mImageNosun.setImageResource(R.drawable.ic_main_tab_search_normal); mImageBusstop.setImageResource(R.drawable.ic_main_tab_stop_pressed); mImageLocation.setImageResource(R.drawable.ic_main_tab_compass_normal); tracker.trackEvent("TabClicks", // Category "BusStopSearch", // Action "", // Label 0); // Value break; case TAB_LOCATION: mLayoutFavorite.setVisibility(View.GONE); mLayoutNosun.setVisibility(View.GONE); mLayoutBusstop.setVisibility(View.GONE); mLayoutLocation.setVisibility(View.VISIBLE); mTabFavorite.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabNosun.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabBusstop.setBackgroundColor(Color.parseColor("#F7F7F0")); mTabLocation.setBackgroundColor(Color.parseColor("#7F7F72")); mTextFavorite.setTextColor(Color.parseColor("#7F7F72")); mTextNosun.setTextColor(Color.parseColor("#7F7F72")); mTextBusstop.setTextColor(Color.parseColor("#7F7F72")); mTextSetting.setTextColor(Color.parseColor("#FFFFFF")); mImageFavorite.setImageResource(R.drawable.ic_main_tab_favorite_normal); mImageNosun.setImageResource(R.drawable.ic_main_tab_search_normal); mImageBusstop.setImageResource(R.drawable.ic_main_tab_stop_normal); mImageLocation.setImageResource(R.drawable.ic_main_tab_compass_pressed); tracker.trackEvent("TabClicks", // Category "Information", // Action "", // Label 0); // Value if (!mBusanBusPrefrence.getIsLocationAgree()) { DialogInterface.OnClickListener cancel = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setTabChange(TAB_NOSUN); } }; DialogInterface.OnClickListener ok = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mBusanBusPrefrence.setLocationAgree(); initilizeMap(); loadLocation(); } }; new AlertDialog.Builder(this).setTitle(" ").setMessage( "Google . .") .setPositiveButton("", ok).setNegativeButton("", cancel).show(); } else { initilizeMap(); loadLocation(); } break; } }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }/*from w ww . java 2 s . c om*/ //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); additionalPaymentTypeMap.clear(); additionalPaymentTypeMap = presenter.filterPaymentTypes(collectionSheetResponse.getPaymentTypeOptions(), paymentTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_loan_product, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } for (SavingsProduct savingsProduct : collectionSheetResponse.getSavingsProducts()) { TextView tvSavingProduct = new TextView(getContext()); tvSavingProduct.setText(getString(R.string.collection_saving_product, savingsProduct.getName())); tvSavingProduct.setTypeface(tvSavingProduct.getTypeface(), Typeface.BOLD); tvSavingProduct.setGravity(Gravity.CENTER); headingRow.addView(tvSavingProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loan : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loan.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText // in format 'TYPE:ID' which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loan.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } //After Loans, show Savings columns for (SavingsProduct product : collectionSheetResponse.getSavingsProducts()) { //Since there may be several Savings items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the Savings in of this type and add in the container for (SavingsCollectionSheet saving : clientCollectionSheet.getSavings()) { if (saving.getProductId() == product.getId()) { //Add the saving in the container EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the Saving id as the Tag of the EditText // in 'TYPE:ID' format which //will later be used as the identifier for this. editText.setTag(TYPE_SAVING + ":" + saving.getSavingsId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); //Set the clientId as its tag which will be used as identifier later. spAttendance.setTag(clientCollectionSheet.getClientId()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that means the CollectionSheet //which is already shown is for groups. btnSubmitProductive.setTag(TAG_TYPE_COLLECTION); if (tableAdditional.getVisibility() != View.VISIBLE) { tableAdditional.setVisibility(View.VISIBLE); } //Show Additional Views TableRow rowPayment = new TableRow(getContext()); TextView tvLabelPayment = new TextView(getContext()); tvLabelPayment.setText(getString(R.string.payment_type)); rowPayment.addView(tvLabelPayment); Spinner spPayment = new Spinner(getContext()); setSpinner(spPayment, paymentTypes); rowPayment.addView(spPayment); tableAdditional.addView(rowPayment); TableRow rowAccount = new TableRow(getContext()); TextView tvLabelAccount = new TextView(getContext()); tvLabelAccount.setText(getString(R.string.account_number)); rowAccount.addView(tvLabelAccount); EditText etPayment = new EditText(getContext()); rowAccount.addView(etPayment); tableAdditional.addView(rowAccount); TableRow rowCheck = new TableRow(getContext()); TextView tvLabelCheck = new TextView(getContext()); tvLabelCheck.setText(getString(R.string.cheque_number)); rowCheck.addView(tvLabelCheck); EditText etCheck = new EditText(getContext()); rowCheck.addView(etCheck); tableAdditional.addView(rowCheck); TableRow rowRouting = new TableRow(getContext()); TextView tvLabelRouting = new TextView(getContext()); tvLabelRouting.setText(getString(R.string.routing_code)); rowRouting.addView(tvLabelRouting); EditText etRouting = new EditText(getContext()); rowRouting.addView(etRouting); tableAdditional.addView(rowRouting); TableRow rowReceipt = new TableRow(getContext()); TextView tvLabelReceipt = new TextView(getContext()); tvLabelReceipt.setText(getString(R.string.receipt_number)); rowReceipt.addView(tvLabelReceipt); EditText etReceipt = new EditText(getContext()); rowReceipt.addView(etReceipt); tableAdditional.addView(rowReceipt); TableRow rowBank = new TableRow(getContext()); TextView tvLabelBank = new TextView(getContext()); tvLabelBank.setText(getString(R.string.bank_number)); rowBank.addView(tvLabelBank); EditText etBank = new EditText(getContext()); rowBank.addView(etBank); tableAdditional.addView(rowBank); }
From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java
/** * This is the main point where we do our initialization of the input method * to begin operating on an application. At this point we have been * bound to the client, and are now receiving all of the detailed information * about the target of our edits.// ww w . ja va 2 s . co m */ @Override public void onStartInput(EditorInfo attribute, boolean restarting) { super.onStartInput(attribute, restarting); // Reset our state. We want to do this even if restarting, because // the underlying state of the text editor could have changed in any way. mComposing.setLength(0); updateCandidates(); if (!restarting) { // Clear shift states. mMetaState = 0; } mPredictionOn = false; mCompletionOn = false; mCompletions = null; // We are now going to initialize our state based on the type of // text being edited. switch (attribute.inputType & InputType.TYPE_MASK_CLASS) { case InputType.TYPE_CLASS_NUMBER: case InputType.TYPE_CLASS_DATETIME: // Numbers and dates default to the symbols keyboard, with // no extra features. mCurKeyboard = mSymbolsKeyboard; break; case InputType.TYPE_CLASS_PHONE: // Phones will also default to the symbols keyboard, though // often you will want to have a dedicated phone keyboard. mCurKeyboard = mSymbolsKeyboard; break; case InputType.TYPE_CLASS_TEXT: // This is general text editing. We will default to the // normal alphabetic keyboard, and assume that we should // be doing predictive text (showing candidates as the // user types). mCurKeyboard = mQwertyKeyboard; mPredictionOn = true; //mPredictionOn = false; // We now look for a few special variations of text that will // modify our behavior. int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION; if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { // Do not display predictions / what the user is typing // when they are entering a password. mPredictionOn = false; } if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == InputType.TYPE_TEXT_VARIATION_URI || variation == InputType.TYPE_TEXT_VARIATION_FILTER) { // Our predictions are not useful for e-mail addresses // or URIs. mPredictionOn = false; } if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) { // If this is an auto-complete text view, then our predictions // will not be shown and instead we will allow the editor // to supply their own. We only show the editor's // candidates when in fullscreen mode, otherwise relying // own it displaying its own UI. mPredictionOn = false; mCompletionOn = isFullscreenMode(); } // We also want to look at the current state of the editor // to decide whether our alphabetic keyboard should start out // shifted. updateShiftKeyState(attribute); break; default: // For all unknown input types, default to the alphabetic // keyboard with no special features. mCurKeyboard = mQwertyKeyboard; updateShiftKeyState(attribute); } // Update the label on the enter key, depending on what the application // says it will do. mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions); }
From source file:com.google.android.apps.tvremote.DeviceFinder.java
private AlertDialog buildManualIpDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); // hwang 2013-12-01 // R.layout.manual_ip? ... View view = LayoutInflater.from(this).inflate(R.layout.manual_ip, null); final EditText ipEditText = (EditText) view.findViewById(R.id.manual_ip_entry); ipEditText.setFilters(new InputFilter[] { new NumberKeyListener() { @Override//from w ww . j a v a 2 s. c o m protected char[] getAcceptedChars() { return "0123456789.:".toCharArray(); } public int getInputType() { return InputType.TYPE_CLASS_NUMBER; } } }); builder.setPositiveButton(R.string.manual_ip_connect, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { RemoteDevice remoteDevice = remoteDeviceFromString(ipEditText.getText().toString()); if (remoteDevice != null) { connectToEntry(remoteDevice); } else { Toast.makeText(DeviceFinder.this, getString(R.string.manual_ip_error_address), Toast.LENGTH_LONG).show(); } } }).setNegativeButton(R.string.manual_ip_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setCancelable(true).setTitle(R.string.manual_ip_label).setMessage(R.string.manual_ip_entry_label) .setView(view); return builder.create(); }
From source file:foam.mongoose.StarwispBuilder.java
public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) { try {// w ww . j av a2 s .co m String type = arr.getString(0); //Log.i("starwisp","building started "+type); if (type.equals("build-fragment")) { String name = arr.getString(1); int ID = arr.getInt(2); Fragment fragment = ActivityManager.GetFragment(name); LinearLayout inner = new LinearLayout(ctx); inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); inner.setId(ID); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(ID, fragment); fragmentTransaction.commit(); parent.addView(inner); return; } if (type.equals("linear-layout")) { LinearLayout v = new LinearLayout(ctx); v.setId(arr.getInt(1)); v.setOrientation(BuildOrientation(arr.getString(2))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); //v.setPadding(2,2,2,2); JSONArray col = arr.getJSONArray(4); v.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("frame-layout")) { FrameLayout v = new FrameLayout(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } /* if (type.equals("grid-layout")) { GridLayout v = new GridLayout(ctx); v.setId(arr.getInt(1)); v.setRowCount(arr.getInt(2)); //v.setColumnCount(arr.getInt(2)); v.setOrientation(BuildOrientation(arr.getString(3))); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); parent.addView(v); JSONArray children = arr.getJSONArray(5); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } return; } */ if (type.equals("scroll-view")) { HorizontalScrollView v = new HorizontalScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("scroll-view-vert")) { ScrollView v = new ScrollView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } return; } if (type.equals("view-pager")) { ViewPager v = new ViewPager(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.setOffscreenPageLimit(3); final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } return null; } }); parent.addView(v); return; } if (type.equals("space")) { // Space v = new Space(ctx); (class not found runtime error??) TextView v = new TextView(ctx); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); parent.addView(v); } if (type.equals("image-view")) { ImageView v = new ImageView(ctx); v.setId(arr.getInt(1)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); String image = arr.getString(2); if (image.startsWith("/")) { Bitmap bitmap = BitmapFactory.decodeFile(image); v.setImageBitmap(bitmap); } else { int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName()); v.setImageResource(id); } parent.addView(v); } if (type.equals("text-view")) { TextView v = new TextView(ctx); v.setId(arr.getInt(1)); v.setText(Html.fromHtml(arr.getString(2))); v.setTextSize(arr.getInt(3)); v.setMovementMethod(LinkMovementMethod.getInstance()); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); if (arr.length() > 5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity) ctx).m_Typeface); parent.addView(v); } if (type.equals("debug-text-view")) { TextView v = (TextView) ctx.getLayoutInflater().inflate(R.layout.debug_text, null); // v.setBackgroundResource(R.color.black); v.setId(arr.getInt(1)); // v.setText(Html.fromHtml(arr.getString(2))); // v.setTextColor(R.color.white); // v.setTextSize(arr.getInt(3)); // v.setMovementMethod(LinkMovementMethod.getInstance()); // v.setMaxLines(10); // v.setVerticalScrollBarEnabled(true); // v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); //v.setMovementMethod(new ScrollingMovementMethod()); /* if (arr.length()>5) { if (arr.getString(5).equals("left")) { v.setGravity(Gravity.LEFT); } else { if (arr.getString(5).equals("fill")) { v.setGravity(Gravity.FILL); } else { v.setGravity(Gravity.CENTER); } } } else { v.setGravity(Gravity.LEFT); } v.setTypeface(((StarwispActivity)ctx).m_Typeface);*/ parent.addView(v); } if (type.equals("web-view")) { WebView v = new WebView(ctx); v.setId(arr.getInt(1)); v.setVerticalScrollBarEnabled(false); v.loadData(arr.getString(2), "text/html", "utf-8"); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); parent.addView(v); } if (type.equals("edit-text")) { final EditText v = new EditText(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); String inputtype = arr.getString(4); if (inputtype.equals("text")) { //v.setInputType(InputType.TYPE_CLASS_TEXT); } else if (inputtype.equals("numeric")) { v.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else if (inputtype.equals("email")) { v.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS); } v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(5))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setSingleLine(true); v.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { CallbackArgs(ctx, ctxname, v.getId(), "\"" + s.toString() + "\""); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); parent.addView(v); } if (type.equals("button")) { Button v = new Button(ctx); v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(5); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Callback(ctx, ctxname, v.getId()); } }); parent.addView(v); } if (type.equals("toggle-button")) { ToggleButton v = new ToggleButton(ctx); if (arr.getString(5).equals("fancy")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_fancy, null); } if (arr.getString(5).equals("yes")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_yes, null); } if (arr.getString(5).equals("maybe")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_maybe, null); } if (arr.getString(5).equals("no")) { v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_no, null); } v.setId(arr.getInt(1)); v.setText(arr.getString(2)); v.setTextSize(arr.getInt(3)); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4))); v.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, v.getId(), arg); } }); parent.addView(v); } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); v.setId(arr.getInt(1)); v.setMax(arr.getInt(2)); v.setProgress(arr.getInt(2) / 2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); final String fn = arr.getString(4); v.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar v, int a, boolean s) { CallbackArgs(ctx, ctxname, v.getId(), Integer.toString(a)); } public void onStartTrackingTouch(SeekBar v) { } public void onStopTrackingTouch(SeekBar v) { } }); parent.addView(v); } if (type.equals("spinner")) { Spinner v = new Spinner(ctx); final int wid = arr.getInt(1); v.setId(wid); final JSONArray items = arr.getJSONArray(2); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, R.layout.spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); v.setAdapter(spinnerArrayAdapter); v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { try { CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\""); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } } public void onNothingSelected(AdapterView<?> v) { } }); parent.addView(v); } if (type.equals("canvas")) { StarwispCanvas v = new StarwispCanvas(ctx); final int wid = arr.getInt(1); v.setId(wid); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); v.SetDrawList(arr.getJSONArray(3)); parent.addView(v); } if (type.equals("camera-preview")) { PictureTaker pt = new PictureTaker(); CameraPreview v = new CameraPreview(ctx, pt); final int wid = arr.getInt(1); v.setId(wid); // LinearLayout.LayoutParams lp = // new LinearLayout.LayoutParams(minWidth, minHeight, 1); v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2))); // v.setLayoutParams(lp); parent.addView(v); } if (type.equals("button-grid")) { LinearLayout horiz = new LinearLayout(ctx); final int id = arr.getInt(1); final String buttontype = arr.getString(2); horiz.setId(id); horiz.setOrientation(LinearLayout.HORIZONTAL); parent.addView(horiz); int height = arr.getInt(3); int textsize = arr.getInt(4); LinearLayout.LayoutParams lp = BuildLayoutParams(arr.getJSONArray(5)); JSONArray buttons = arr.getJSONArray(6); int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = arr.getString(6); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } } } } catch (JSONException e) { Log.e("starwisp", "Error parsing [" + arr.toString() + "] " + e.toString()); } //Log.i("starwisp","building ended"); }
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);/*from w w w .j a va 2 s.co 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:com.roque.rueda.cashflows.fragments.AddMovementFragment.java
/** * Creates the input amount dialog./*from w w w . j a v a 2 s . c o m*/ * @param parentActivity Activity used to access application resources. */ private void buildInputMoneyDialog(Activity parentActivity) { AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity, AlertDialog.THEME_HOLO_DARK); builder.setTitle(getString(R.string.amount_dialog_title)); builder.setMessage(getString(R.string.amount_dialog_label)); builder.setPositiveButton(getString(R.string.save_amount), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Set text of the dialog edit text to the amount button. double amountText = 0; String dialogText = mAmountTextDago.getText().toString(); if (dialogText != null && !dialogText.isEmpty()) { amountText = Double.valueOf(dialogText); } // Close this dialog. dialog.dismiss(); mButtonAmount.setText(StringFormatter.formatCurrency(amountText)); } }); builder.setNegativeButton(getString(R.string.cancel_amount), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Cancel this dialog. dialog.cancel(); } }); // Setup the input for the user. mAmountTextDago = new EditText(parentActivity); mAmountTextDago.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); mAmountTextDago.setGravity(Gravity.RIGHT); mAmountTextDago.setFilters(new InputFilter[] { new DecimalDigitsInputFiler(16, 2) }); mAmountTextDago.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER); mAmountTextDago.setTextColor(getResources().getColor(R.color.text_white)); mAmountTextDago.setTypeface(StringFormatter.createLightFont()); // Assign this view to the dialog. builder.setView(mAmountTextDago); mInputMoneyDialog = builder.create(); displayDialogKeyboard(); }
From source file:com.development.androrb.listfolders.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case 1:// w ww . ja va 2 s. com // This example shows how to add a custom layout to an AlertDialog LayoutInflater factory = LayoutInflater.from(this); final View textEntryView = factory.inflate(R.layout.login_dialog, null); EditText dusernamefield = (EditText) textEntryView.findViewById(R.id.username_edit); dusernamefield.setText(Username); EditText dpasswordfield = (EditText) textEntryView.findViewById(R.id.password_edit); dpasswordfield.setText(Password); return new AlertDialog.Builder(listfolders.this).setIcon(R.drawable.alert_dialog_icon) .setTitle("Login Data").setView(textEntryView) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Dialog curDialog = (Dialog) dialog; EditText dusernamefield = (EditText) curDialog.findViewById(R.id.username_edit); EditText dpasswordfield = (EditText) curDialog.findViewById(R.id.password_edit); String dusername = dusernamefield.getText().toString(); String dpassword = dpasswordfield.getText().toString(); SharedPreferences preferences = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString("UID", dusername); editor.commit(); editor.putString("PW", dpassword); editor.commit(); Intent mainIntent = new Intent(listfolders.this, listfolders.class); listfolders.this.startActivity(mainIntent); listfolders.this.finish(); /* User clicked OK so do some stuff */ } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ } }).create(); case 2: // This example shows how to add a custom layout to an AlertDialog LayoutInflater factory2 = LayoutInflater.from(this); final View apiEntryView = factory2.inflate(R.layout.apikey, null); EditText dapikeyfield = (EditText) apiEntryView.findViewById(R.id.api_edit); dapikeyfield.setText(apikey); return new AlertDialog.Builder(listfolders.this).setIcon(R.drawable.alert_dialog_icon) .setTitle("API KEY").setView(apiEntryView) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Dialog curDialog = (Dialog) dialog; EditText dapikeyfield = (EditText) curDialog.findViewById(R.id.api_edit); String dapikey = dapikeyfield.getText().toString(); SharedPreferences preferences = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString("API", dapikey); editor.commit(); Intent mainIntent = new Intent(listfolders.this, listfolders.class); listfolders.this.startActivity(mainIntent); listfolders.this.finish(); /* User clicked OK so do some stuff */ } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ } }).create(); case 3: // This example shows how to add a custom layout to an AlertDialog LayoutInflater factory3 = LayoutInflater.from(this); final View maxEntryView = factory3.inflate(R.layout.maxcount, null); EditText dmaxkeyfield = (EditText) maxEntryView.findViewById(R.id.maxcount_edit); dmaxkeyfield.setText(maxcount); dmaxkeyfield.setKeyListener(new NumberKeyListener() { @Override protected char[] getAcceptedChars() { char[] numberChars = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; return numberChars; } @Override public int getInputType() { return InputType.TYPE_CLASS_NUMBER; } }); return new AlertDialog.Builder(listfolders.this).setIcon(R.drawable.alert_dialog_icon) .setTitle("Max Item p.Page").setView(maxEntryView) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Dialog curDialog = (Dialog) dialog; EditText dmaxkeyfield = (EditText) curDialog.findViewById(R.id.maxcount_edit); String dmaxcount = dmaxkeyfield.getText().toString(); int idmaxcount = Integer.parseInt(dmaxcount); if (idmaxcount < 10) dmaxcount = "10"; if (idmaxcount > 500) dmaxcount = "500"; SharedPreferences preferences = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString("MAX", dmaxcount); editor.commit(); Intent mainIntent = new Intent(listfolders.this, listfolders.class); listfolders.this.startActivity(mainIntent); listfolders.this.finish(); /* User clicked OK so do some stuff */ } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ } }).create(); } return null; }