List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:com.doplgangr.secrecy.settings.SettingsFragment.java
void choosePath(final getFileListener listener) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(context); builderSingle.setTitle(context.getString(R.string.Settings__select_storage_title)); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, R.layout.select_dialog_singlechoice); final Map<String, File> storages = Util.getAllStorageLocations(); for (String key : storages.keySet()) { arrayAdapter.add(key);//ww w . j av a 2 s. com } builderSingle.setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); File file = storages.get(strName); listener.get(file); } }); builderSingle.show(); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
private void showDialogSelectApp(final String[] applications) { // Show Dialog AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setTitle("Application List"); ab.setIcon(R.drawable.ic_launcher);/*from w w w . j a v a 2 s . c om*/ ab.setSingleChoiceItems(applications, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { selectedOveralyIndex = position; } }).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { if (position >= 0) { selectedOveralyIndex = position; } else if (applications.length > 0 && selectedOveralyIndex == -1) { selectedOveralyIndex = 0; } String application = applications[selectedOveralyIndex]; runStandAlone(application); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { return; } }); ab.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java
private void stopUseBeacon(int position) { final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ?"); alertDialog.setMessage("? ? ?"); alertDialog.setIcon(R.drawable.alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateEvent("BEACON_STOP"); StopUseBeacon stopUseBeacon = new StopUseBeacon(); stopUseBeacon.execute("http://125.131.73.198:3000/beaconStop", beaconmac); }// w w w .j a v a 2 s. c om }); alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:com.code.android.vibevault.SearchScreen.java
/** Handle user's long-click selection. * *///from www .j a v a 2 s.c o m @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (menuInfo != null) { ArchiveShowObj selShow = (ArchiveShowObj) searchList.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case VibeVault.EMAIL_LINK: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great show on archive.org: " + selShow.getArtistAndTitle()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ". You can find it here: " + selShow.getShowURL() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); return true; case VibeVault.SHOW_INFO: AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Show Info"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null); ((TextView) v.findViewById(R.id.DialogText)).setText(selShow.getSource()); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { } }); ad.setView(v); ad.show(); return true; case (VibeVault.ADD_TO_FAVORITE_LIST): VibeVault.db.insertFavoriteShow(selShow); return true; default: return false; } } return false; }
From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java
private void showError(Intent intent) { final String errorMessage = intent.getStringExtra(ERROR_MESSAGE); if (TextUtils.isEmptyOrWhitespace(errorMessage)) { finish();/*from www . j a v a 2s . c o m*/ showErrorToast(); } else { final String errorCaption = intent.getStringExtra(ERROR_CAPTION); final String errorAction = intent.getStringExtra(ERROR_ACTION); final String errorTitle = intent.getStringExtra(ERROR_TITLE); final AlertDialog.Builder builder = new AlertDialog.Builder(ProcessScanActivity.this); builder.setTitle(errorTitle); builder.setMessage(errorMessage); builder.setNegativeButton(R.string.rogerthat, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); if (!TextUtils.isEmptyOrWhitespace(errorCaption) && !TextUtils.isEmptyOrWhitespace(errorAction)) { builder.setPositiveButton(errorCaption, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(errorAction)); startActivity(intent); dialog.dismiss(); finish(); } }); } builder.show(); } }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityAddPickupAndDropoff.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Getting the selected journey Journey journey = getApp().getSelectedJourney(); // Setting up tabs TabHost tabs = (TabHost) findViewById(R.id.tabhost); tabs.setup();/*w w w . java 2s . c om*/ // Adding Ride tab TabHost.TabSpec specRide = tabs.newTabSpec("tag1"); specRide.setContent(R.id.ride_tab); specRide.setIndicator("Ride"); tabs.addTab(specRide); // Adding Driver tab TabHost.TabSpec specDriver = tabs.newTabSpec("tag2"); specDriver.setContent(R.id.driver_tab); specDriver.setIndicator("Driver"); tabs.addTab(specDriver); // Adding the pickup location address text ((AutoCompleteTextView) findViewById(R.id.pickupText)) .setText(getIntent().getExtras().getString("pickupString")); // Adding the dropoff location address text ((AutoCompleteTextView) findViewById(R.id.dropoffText)) .setText(getIntent().getExtras().getString("dropoffString")); // Drawing the pickup and dropoff locations on the map setPickupLocation(); setDropOffLocation(); // Adding image of the driver User driver = journey.getRoute().getOwner(); picture = (ImageView) findViewById(R.id.mapViewPickupImage); // Create an object for subclass of AsyncTask GetImage task = new GetImage(picture, this); // Execute the task: Get image from url and add it to the ImageView task.execute(driver.getPictureURL()); // Adding the name of the driver ((TextView) findViewById(R.id.mapViewPickupTextViewName)).setText(driver.getFullName()); // Getting the drivers preferences for this ride TripPreferences pref = journey.getTripPreferences(); // Setting the smoking preference if (pref.getSmoking()) { ((ImageView) findViewById(R.id.mapViewPickupImageViewSmokingIcon)) .setImageResource(R.drawable.green_check); } else { ((ImageView) findViewById(R.id.mapViewPickupImageViewSmokingIcon)) .setImageResource(R.drawable.red_cross); } // Setting the animals preference if (pref.getAnimals()) { ((ImageView) findViewById(R.id.mapViewPickupImageViewAnimalsIcon)) .setImageResource(R.drawable.green_check); } else { ((ImageView) findViewById(R.id.mapViewPickupImageViewAnimalsIcon)) .setImageResource(R.drawable.red_cross); } // Setting the breaks preference if (pref.getBreaks()) { ((ImageView) findViewById(R.id.mapViewPickupImageViewBreaksIcon)) .setImageResource(R.drawable.green_check); } else { ((ImageView) findViewById(R.id.mapViewPickupImageViewBreaksIcon)) .setImageResource(R.drawable.red_cross); } // Setting the music preference if (pref.getMusic()) { ((ImageView) findViewById(R.id.mapViewPickupImageViewMusicIcon)) .setImageResource(R.drawable.green_check); } else { ((ImageView) findViewById(R.id.mapViewPickupImageViewMusicIcon)).setImageResource(R.drawable.red_cross); } // Setting the talking preference if (pref.getTalking()) { ((ImageView) findViewById(R.id.mapViewPickupImageViewTalkingIcon)) .setImageResource(R.drawable.green_check); } else { ((ImageView) findViewById(R.id.mapViewPickupImageViewTalkingIcon)) .setImageResource(R.drawable.red_cross); } // Setting the number of available seats ((TextView) findViewById(R.id.mapViewPickupTextViewSeats)) .setText(pref.getSeatsAvailable() + " available seats"); // Setting the age of the driver ((TextView) findViewById(R.id.mapViewPickupTextViewAge)).setText("Age: " + driver.getAge()); // Adding the gender of the driver if (driver.getGender() != null) { if (driver.getGender().equals("m")) { ((ImageView) findViewById(R.id.mapViewPickupImageViewGender)).setImageResource(R.drawable.male); } else if (driver.getGender().equals("f")) { ((ImageView) findViewById(R.id.mapViewPickupImageViewGender)).setImageResource(R.drawable.female); } } // Addring the rating of the driver ((TextView) findViewById(R.id.recommendations)).setText("Recommendations: " + (int) driver.getRating()); // Setting the drivers mobile number ((TextView) findViewById(R.id.mapViewPickupTextViewPhone)).setText("Mobile: " + driver.getPhone()); try { // Getting the car image Car dummyCar = new Car(driver.getCarId(), "Dummy", 0.0); //"Dummy" and 0.0 are dummy vars. getApp() etc sends the current user's carid Request carReq = new CarRequest(RequestType.GET_CAR, getApp().getUser(), dummyCar); CarResponse carRes = (CarResponse) RequestTask.sendRequest(carReq, getApp()); Car car = carRes.getCar(); Bitmap carImage = BitmapFactory.decodeByteArray(car.getPhoto(), 0, car.getPhoto().length); // Setting the car image ((ImageView) findViewById(R.id.mapViewPickupImageViewCar)).setImageBitmap(carImage); // Setting the car name ((TextView) findViewById(R.id.mapViewPickupTextViewCarName)).setText("Car type: " + car.getCarName()); // Setting the comfort ((RatingBar) findViewById(R.id.mapViewPickupAndDropoffComfortStars)) .setRating((float) car.getComfort()); } catch (ClientProtocolException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ExecutionException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Adding the date of ride Date d = journey.getStart().getTime(); SimpleDateFormat sdfDate = new SimpleDateFormat("MMM dd yyyy"); SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm zzz"); String dateText = "Date: " + sdfDate.format(d); String timeText = "Time: " + sdfTime.format(d); ((TextView) findViewById(R.id.mapViewPickupTextViewDate)).setText(dateText + "\n" + timeText); //Adding Gender to the driver ImageView iv_image; iv_image = (ImageView) findViewById(R.id.gender); try { if (driver.getGender().equals("Male")) { Drawable male = getResources().getDrawable(R.drawable.male); iv_image.setImageDrawable(male); } else if (driver.getGender().equals("Female")) { Drawable female = getResources().getDrawable(R.drawable.female); iv_image.setImageDrawable(female); } } catch (NullPointerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Initializing the two autocomplete textviews pickup and dropoff initAutocomplete(); // Adding onClickListener for the button "Ask for a ride" btnSendRequest = (Button) findViewById(no.ntnu.idi.socialhitchhiking.R.id.mapViewPickupBtnSendRequest); btnSendRequest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Response res; NotificationRequest req; if (pickupPoint == null || dropoffPoint == null) { //makeToast("You have to choose pickup point and dropoff point."); AlertDialog.Builder ad = new AlertDialog.Builder(MapActivityAddPickupAndDropoff.this); ad.setMessage("You have to choose pickup point and dropoff point."); ad.setTitle("Unable to send request"); ad.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); ad.show(); return; } inPickupMode = true; String senderID = getApp().getUser().getID(); String recipientID = getApp().getSelectedJourney().getRoute().getOwner().getID(); String senderName = getApp().getUser().getFullName(); String comment = ((EditText) findViewById(R.id.mapViewPickupEtComment)).getText().toString(); int journeyID = getApp().getSelectedJourney().getSerial(); // Creating a new notification to be sendt to the driver Notification n = new Notification(senderID, recipientID, senderName, comment, journeyID, NotificationType.HITCHHIKER_REQUEST, pickupPoint, dropoffPoint, Calendar.getInstance()); req = new NotificationRequest(RequestType.SEND_NOTIFICATION, getApp().getUser(), n); // Sending notification try { res = RequestTask.sendRequest(req, getApp()); if (res instanceof UserResponse) { if (res.getStatus() == ResponseStatus.OK) { makeToast("Ride request sent to driver"); finish(); } if (res.getStatus() == ResponseStatus.FAILED) { if (res.getErrorMessage().contains("no_duplicate_notifications")) { //makeToast("You have already sent a request on this journey"); AlertDialog.Builder ad = new AlertDialog.Builder( MapActivityAddPickupAndDropoff.this); ad.setMessage("You have already sent a request on this ride"); ad.setTitle("Unable to send request"); ad.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); ad.show(); } else if (res.getErrorMessage().equals("No available seats")) { //makeToast("There are no available seats on this ride"); AlertDialog.Builder ad = new AlertDialog.Builder( MapActivityAddPickupAndDropoff.this); ad.setMessage("There are no available seats on this ride"); ad.setTitle("Unable to send request"); ad.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); ad.show(); } else if (res.getErrorMessage().equals("User already in journey")) { //makeToast("You have already hitched this ride"); AlertDialog.Builder ad = new AlertDialog.Builder( MapActivityAddPickupAndDropoff.this); ad.setMessage("You have already hitched this ride"); ad.setTitle("Unable to send request"); ad.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); ad.show(); } else { makeToast("Could not send request"); } } } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); // Adding buttons where you choose between pickup point and dropoff point btnSelectPickupPoint = (Button) findViewById(R.id.mapViewPickupBtnPickup); btnSelectPickupPoint.setBackgroundColor(notSelected); btnSelectDropoffPoint = (Button) findViewById(R.id.mapViewPickupBtnDropoff); btnSelectDropoffPoint.setBackgroundColor(notSelected); // Setting the selected pickup point btnSelectPickupPoint.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { isSelectingDropoffPoint = false; isSelectingPickupPoint = true; btnSelectPickupPoint.setBackgroundColor(selected); btnSelectDropoffPoint.setBackgroundColor(notSelected); makeToast("Press the map to add pickup location"); } }); // Setting the selected dropoff point btnSelectDropoffPoint.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { isSelectingDropoffPoint = true; isSelectingPickupPoint = false; btnSelectPickupPoint.setBackgroundColor(notSelected); btnSelectDropoffPoint.setBackgroundColor(selected); makeToast("Press the map to add dropoff location"); } }); // Adding message to the user makeToast("Please set a pickup and dropoff location."); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java
private void updateUseBeacon(int usingPosition, int position) { final String usingBeaconmac = mMyDeviceAdapter.getDeviceList().get(usingPosition).getBdAddr(); final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ?"); alertDialog.setMessage("? ? ?"); alertDialog.setIcon(R.drawable.alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateEvent("BEACON_USE"); UpdateUseBeacon updateUseBeacon = new UpdateUseBeacon(); updateUseBeacon.execute("http://125.131.73.198:3000/beaconUseUpdate", usingBeaconmac, beaconmac); }/* w w w.j a va 2 s . c o m*/ }); alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:com.example.zf_android.trade.ApplyDetailActivity.java
/** * firstly init the merchant category with item keys, * and after user select the merchant the values will be set *//*from ww w .j a v a2 s. co m*/ private void initMerchantDetailKeys() { // the first category mMerchantKeys = getResources().getStringArray(R.array.apply_detail_merchant_keys); mMerchantContainer.addView(getDetailItem(ITEM_CHOOSE, mMerchantKeys[0], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[1], null)); LinearLayout ll = getDetailItem(ITEM_EDIT, mMerchantKeys[2], null); etMerchantName = (EditText) ll.findViewById(R.id.apply_detail_value); etMerchantName.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { etBankMerchantName.setText(s.toString()); } @Override public void afterTextChanged(Editable s) { etBankMerchantName.setText(s.toString()); } }); mMerchantContainer.addView(ll); View merchantGender = getDetailItem(ITEM_CHOOSE, mMerchantKeys[3], null); merchantGender.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this); final String[] items = getResources().getStringArray(R.array.apply_detail_gender); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setItemValue(mMerchantKeys[3], items[which]); } }); builder.show(); } }); mMerchantContainer.addView(merchantGender); View merchantBirthday = getDetailItem(ITEM_CHOOSE, mMerchantKeys[4], null); merchantBirthday.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CommonUtil.showDatePicker(ApplyDetailActivity.this, mMerchantBirthday, new CommonUtil.OnDateSetListener() { @Override public void onDateSet(String date) { setItemValue(mMerchantKeys[4], date); } }); } }); mMerchantContainer.addView(merchantBirthday); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[5], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[6], null)); mMerchantContainer.addView(getDetailItem(ITEM_EDIT, mMerchantKeys[7], null)); View merchantCity = getDetailItem(ITEM_CHOOSE, mMerchantKeys[8], null); merchantCity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, CityProvinceActivity.class); intent.putExtra(SELECTED_PROVINCE, mMerchantProvince); intent.putExtra(SELECTED_CITY, mMerchantCity); startActivityForResult(intent, REQUEST_CHOOSE_CITY); } }); mMerchantContainer.addView(merchantCity); // the second category mBankKeys = getResources().getStringArray(R.array.apply_detail_bank_keys); mCustomerContainer.addView(getDetailItem(ITEM_CHOOSE, mBankKeys[0], null)); LinearLayout tmpll = (LinearLayout) mContainer.findViewWithTag(mBankKeys[0]); tmpll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { customTag = mBankKeys[0]; Intent intent = new Intent(ApplyDetailActivity.this, BankList.class); intent.putExtra(AGENT_NAME, mBankName); intent.putExtra("terminalId", mTerminalId); startActivityForResult(intent, REQUEST_CHOOSE_BANK); } }); View bankAccountName = getDetailItem(ITEM_EDIT, mBankKeys[1], null); etBankMerchantName = (EditText) bankAccountName.findViewById(R.id.apply_detail_value); etBankMerchantName.setEnabled(false); mCustomerContainer.addView(bankAccountName); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[2], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[3], null)); mCustomerContainer.addView(getDetailItem(ITEM_EDIT, mBankKeys[4], null)); View chooseChannel = getDetailItem(ITEM_CHOOSE, getString(R.string.apply_detail_channel), null); chooseChannel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ApplyDetailActivity.this, ChannelSelecter.class); startActivityForResult(intent, REQUEST_CHOOSE_CHANNEL); } }); mCustomerContainer.addView(chooseChannel); }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // it removes the title from the actionbar(more space for icons?) // this.getActionBar().setDisplayShowTitleEnabled(false); pixels5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); LinearLayout parent = new LinearLayout(this); parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); parent.setOrientation(LinearLayout.VERTICAL); LinearLayout scrollViewParent = new LinearLayout(this); scrollViewParent.setLayoutParams(/* w ww . jav a 2 s .c om*/ new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); scrollViewParent.setOrientation(LinearLayout.HORIZONTAL); HorizontalScrollView predictionsHorizontalScrollView = new HorizontalScrollView(this); //predictionsHorizontalScrollView.setLayoutParams(new ViewGroup.LayoutParams()); predictions = new LinearLayout(this); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); params.gravity = Gravity.CENTER_VERTICAL; predictions.setLayoutParams(params); predictions.setOrientation(LinearLayout.HORIZONTAL); resetPredictionsView(predictions, true); predictionsHorizontalScrollView.addView(predictions); saveButton = new Button(this); saveButton.setText("Send Feedback"); predictionsHorizontalScrollView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 10.0f)); saveButton.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); saveButton.setVisibility(View.INVISIBLE); FrameLayout frameLayout = new FrameLayout(this); frameLayout .setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); frameLayout.addView(saveButton); loader = new ProgressBar(this); loader.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); loader.setIndeterminate(true); loader.setVisibility(ProgressBar.INVISIBLE); frameLayout.addView(loader); scrollViewParent.addView(predictionsHorizontalScrollView); scrollViewParent.addView(frameLayout); contentView = new MyView(this); parent.addView(scrollViewParent); parent.addView(contentView); setContentView(parent); otherLabelOnClickListener = new View.OnClickListener() { @Override public void onClick(View view) { Log.e("Clicked", "Other Label label '" + (String) view.getTag() + "'"); sendScreenshot(false, feedbackType, (String) view.getTag()); } }; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(DEFAULT_BRUSH_SIZE); // Where did these magic numbers come from? What do they mean? Can I change them? ~TheOpenSourceNinja // Absolutely random numbers in order to see the emboss. asd! ~Valerio mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL); if (isFirstTime()) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.app_name); alert.setMessage(R.string.app_description); alert.setNegativeButton(R.string.continue_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT) .show(); } }); alert.show(); } else { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show(); } loadFromIntents(); }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void firstRunChecker() { boolean isFirstRun = true; SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); if (!settings.contains("isFirstRun")) { isFirstRun = true;/*from w w w . j av a 2 s. c o m*/ } else { isFirstRun = settings.getBoolean("isFirstRun", false); } if (isFirstRun) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.welcome)); builder.setMessage(getString(R.string.fr)); builder.setPositiveButton("OK", null); builder.show(); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("isFirstRun", false); editor.commit(); } }