List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.bridgeconn.autographago.ui.activities.SettingsActivity.java
private void showLanguageDialog(List<String> languages) { Realm realm = Realm.getDefaultInstance(); ArrayList<LanguageModel> languageModels = query(realm, new AllSpecifications.AllLanguages(), new AllMappers.LanguageMapper()); for (Iterator<String> iterator = languages.iterator(); iterator.hasNext();) { String lan = iterator.next(); for (LanguageModel languageModel : languageModels) { if (languageModel.getLanguageName().equals(lan)) { if (languageModel.getVersionModels().size() == 2) { iterator.remove();//from w w w . j ava2 s . com } } } } realm.close(); if (isFinishing()) { return; } if (languages.size() == 0) { Toast.makeText(this, getResources().getString(R.string.no_new_languages_available), Toast.LENGTH_SHORT) .show(); return; } AlertDialog.Builder builder = null; switch (SharedPrefs.getReadingMode()) { case Day: { builder = new AlertDialog.Builder(this, R.style.DialogThemeLight); break; } case Night: { builder = new AlertDialog.Builder(this, R.style.DialogThemeDark); break; } } final View view = LayoutInflater.from(this).inflate(R.layout.dialog_languages, (ViewGroup) findViewById(android.R.id.content), false); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list_items); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setHasFixedSize(true); builder.setView(view); view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { int maxHeight = UtilFunctions.dpToPx(SettingsActivity.this, 300); @Override public void onGlobalLayout() { if (view.getHeight() > maxHeight) view.getLayoutParams().height = maxHeight; } }); builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setTitle(getString(R.string.select_language)); AlertDialog dialog = builder.create(); dialog.show(); DownloadDialogAdapter dialogAdapter = new DownloadDialogAdapter(this, dialog, languages, null, null); recyclerView.setAdapter(dialogAdapter); }
From source file:com.bridgeconn.autographago.ui.activities.SettingsActivity.java
private void showVersionDialog(List<String> versions, String language) { Realm realm = Realm.getDefaultInstance(); ArrayList<LanguageModel> languageModels = query(realm, new AllSpecifications.AllLanguages(), new AllMappers.LanguageMapper()); for (Iterator<String> iterator = versions.iterator(); iterator.hasNext();) { String ver = iterator.next(); for (LanguageModel languageModel : languageModels) { if (languageModel.getLanguageName().equals(language)) { for (VersionModel versionModel : languageModel.getVersionModels()) { if (versionModel.getVersionCode().equals(ver)) { iterator.remove(); }// w w w. j a v a2s .c o m } } } } realm.close(); if (isFinishing()) { return; } if (versions.size() == 0) { Toast.makeText(this, getResources().getString(R.string.no_new_versions_available), Toast.LENGTH_SHORT) .show(); return; } AlertDialog.Builder builder = null; switch (SharedPrefs.getReadingMode()) { case Day: { builder = new AlertDialog.Builder(this, R.style.DialogThemeLight); break; } case Night: { builder = new AlertDialog.Builder(this, R.style.DialogThemeDark); break; } } final View view = LayoutInflater.from(this).inflate(R.layout.dialog_languages, (ViewGroup) findViewById(android.R.id.content), false); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list_items); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setHasFixedSize(true); builder.setView(view); view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { int maxHeight = UtilFunctions.dpToPx(SettingsActivity.this, 300); @Override public void onGlobalLayout() { if (view.getHeight() > maxHeight) view.getLayoutParams().height = maxHeight; } }); builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setTitle(getString(R.string.select_version)); AlertDialog dialog = builder.create(); dialog.show(); DownloadDialogAdapter dialogAdapter = new DownloadDialogAdapter(this, dialog, null, versions, language); recyclerView.setAdapter(dialogAdapter); }
From source file:com.example.android.contactslist.ui.groupsEditor.GroupsEditorFragment.java
private void specifyNewGroupToAdd() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.dialog_title_enter_group_name); // Set up the input final EditText input = new EditText(getActivity()); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); builder.setView(input); // Set up the buttons builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override//from ww w . j a v a2s.c o m public void onClick(DialogInterface dialog, int which) { final GoogleGroupMaker googleGroupMaker = new GoogleGroupMaker(getActivity()); name_of_new_group = input.getText().toString(); // create new group with the given name googleGroupMaker.makeContactGroup(name_of_new_group); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:cat.wuyingren.rorhelper.fragments.dialogs.NewGameDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.dialog_newgame, null); Spinner playerSpin = SystemUtils.configureSpinner(v, R.id.newgame_playersSpinner, R.array.numberofplayers); playerSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/* w w w .ja va 2 s.c om*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { result.setPlayers(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); Spinner scenarioSpin = SystemUtils.configureSpinner(v, R.id.newgame_scenarioSpinner, R.array.scenariolist); scenarioSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { result.setScenario(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final EditText nameText = (EditText) v.findViewById(R.id.newgame_nameText); builder.setView(v).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { result.setName(nameText.getText().toString()); mListener.onNewGameDialogClick(result); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }).setTitle(getString(R.string.dialog_newgame_title)); return builder.create(); }
From source file:bikebadger.RideFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(Constants.APP.TAG, "RideFragment.onCreateView()"); setRetainInstance(true);//from w w w . j a v a2 s .co m View view = inflater.inflate(R.layout.fragment_run, container, false); mMessagebarView = (TextView) view.findViewById(R.id.run_messagebarView); mStartedTextView = (TextView) view.findViewById(R.id.run_startedTextView); mDurationTextView = (TextView) view.findViewById(R.id.run_durationTextView); mSpeedTextView = (TextView) view.findViewById(R.id.run_speedTextView); mTargetSpeedTextView = (TextView) view.findViewById(R.id.run_targetSpeedTextView); mAverageSpeedTextView = (TextView) view.findViewById(R.id.run_avgSpeedTextView); mStartStopButton = (ImageButton) view.findViewById(R.id.run_startButton); mTargetEditButton = (Button) view.findViewById(R.id.target_editButton); mArrowView = (ImageView) view.findViewById(R.id.img1); // set up startstop buttons mPlayButtonClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (mRide == null) { startReceivingTimerUpdates(); startReceivingLocationUpdates(); // RideManager starts the location services mRide = mRideManager.startNewRun(); } else { mRideManager.startTrackingRun(mRide); } //MediaUtil.Beep(); mRideManager.SpeakWords("Starting"); updateUI(); mRide.StartStopwatch(); MyToast.Show(getActivity().getApplicationContext(), "Starting", Color.BLACK); } }; mStartStopButton.setOnClickListener(mPlayButtonClickListener); mPauseButtonClickListener = new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); mRideManager.SpeakWords("Stopping"); mRideManager.stopRun(); updateUI(); stopReceivingTimerUpdates(); if (mRide != null) mRide.PauseStopwatch(); MyToast.Show(getActivity().getApplicationContext(), "Stopped", Color.BLACK); } }; // Reset the average mResetButton = (ImageButton) view.findViewById(R.id.run_resetButton); mResetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); if (mRide != null && mRideManager.isTrackingRun(mRide)) { mRide.ResetAverageSpeed(); } updateUI(); } }); mWaypointButton = (ImageButton) view.findViewById(R.id.run_waypointButton); mWaypointButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); Intent waypointIntent = new Intent(getActivity(), WaypointActivity.class); waypointIntent.putExtra("location", mRideManager.GetLastKnowLocation()); startActivityForResult(waypointIntent, Constants.APP.ACTION_WAYPOINT_REQUEST_CODE); updateUI(); } }); mTargetEditButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); final EditText einput = new EditText(getActivity()); alert.setTitle("Target Average Speed"); alert.setMessage("Edit the target average speed."); einput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); einput.setText(mTargetSpeedTextView.getText()); alert.setView(einput); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String sValue = einput.getText().toString(); double targetVal; try { targetVal = Double.parseDouble(sValue); } catch (NumberFormatException nfe) { targetVal = 0; Log.d("RunTracker", "Error parsing mSpeedIntervalSeconds"); } if (targetVal > 78700 && targetVal < 78800) { final SharedPreferences myPrefs = PreferenceManager .getDefaultSharedPreferences(getActivity().getApplicationContext()); myPrefs.edit().putBoolean("Hacked", true).commit(); AppManager.SimpleNotice(getActivity(), "Full Version Hack", "You now have access to the full paid version for free."); //getActivity().finish(); } else { if (mRide != null) { mRide.SetTargetAvgSpeed(targetVal); } else if (mRideManager != null) { mRideManager.SetDefaultTargetAvgSpeed(targetVal); } mTargetSpeedTextView.setText(sValue); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); // do we start now? if (mRideManager != null && mRideManager.IsStartNow()) { startReceivingTimerUpdates(); startReceivingLocationUpdates(); mRide = mRideManager.startNewRun(); mRideManager.SpeakWords("Starting"); } // Trying to fix flicker issue // if(isVisible()) // updateUI(); return view; }
From source file:com.ezac.gliderlogs.FlightDetailActivity.java
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.start_edit); // get references to our objects mDateText = (EditText) findViewById(R.id.flight_date); mRegiSpin = (Spinner) findViewById(R.id.flight_registration); mPilotSpin = (Spinner) findViewById(R.id.flight_pilot); mInstChck = (CheckBox) findViewById(R.id.flight_instruction); mCoPilotSpin = (Spinner) findViewById(R.id.flight_copilot); mStartText = (EditText) findViewById(R.id.flight_start); mLandText = (EditText) findViewById(R.id.flight_landing); mDuraText = (EditText) findViewById(R.id.flight_duration); // disable input, these are output only mDateText.setClickable(false);//from w w w . java 2 s.c om mDateText.setFocusable(false); mStartText.setClickable(false); mStartText.setFocusable(false); mLandText.setClickable(false); mLandText.setFocusable(false); mDuraText.setClickable(false); mDuraText.setFocusable(false); mBodyText = (EditText) findViewById(R.id.flight_edit_notes); mDateText.setText(FlightOverviewActivity.ToDay); mTypeNorm = (CheckBox) findViewById(R.id.flight_type_norm); mTypePass = (CheckBox) findViewById(R.id.flight_type_pass); mTypeDona = (CheckBox) findViewById(R.id.flight_type_dona); mTypeClub = (CheckBox) findViewById(R.id.flight_type_club); mLaunchWinch = (CheckBox) findViewById(R.id.flight_launch_winch); mLaunchTow = (CheckBox) findViewById(R.id.flight_launch_tow); mLaunchMotor = (CheckBox) findViewById(R.id.flight_launch_motor); Button confirmButton = (Button) findViewById(R.id.flight_edit_button); Button exitButton = (Button) findViewById(R.id.flight_quit_button); Button againButton = (Button) findViewById(R.id.flight_again_button); Button timeSButton = (Button) findViewById(R.id.btnChangeSTime); Button timeLButton = (Button) findViewById(R.id.btnChangeLTime); Button clearSButton = (Button) findViewById(R.id.btnClearSTime); Button clearLButton = (Button) findViewById(R.id.btnClearLTime); Button gliderButton = (Button) findViewById(R.id.btn_ext_1); Button pilotButton = (Button) findViewById(R.id.btn_ext_2); Bundle extras = getIntent().getExtras(); // get data from DB tables and load our glider/member list addItemSpinner1(); addItemSpinner2(); // only now check if these are still empty if (GliderList.isEmpty() || MemberList.isEmpty()) { makeToast("Opties -> Voer eerst de actie 'Dag opstarten' uit, mogelijk was er een netwerk probleem !."); setResult(RESULT_CANCELED); finish(); } // check from the saved Instance flightUri = (bundle == null) ? null : (Uri) bundle.getParcelable(FlightsContentProvider.CONTENT_ITEM_TYPE); // Or passed from the other activity if (extras != null) { flightUri = extras.getParcelable(FlightsContentProvider.CONTENT_ITEM_TYPE); fillData(flightUri); } // bewaar ingevoerde informatie confirmButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPilotSpin.getSelectedItem().equals(mCoPilotSpin.getSelectedItem())) { makeToast("'Gezagvoerder' en 'Co-Piloot' kunnen niet het zelfde zijn !!"); } else { if (TextUtils.isEmpty((String) mRegiSpin.getSelectedItem())) { makeToast("Verplichte velden invullen aub"); } else { setResult(RESULT_OK); finish(); } } } }); // dupliceer de geselecteerde vlucht againButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(FlightDetailActivity.this).setTitle("Bevestig deze opdracht") .setMessage("Wilt u deze vlucht dupliceren ? ") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // put some caheck in place as t avoid bogus record to be created if ((!mDateText.getText().toString().equals("")) && (!mStartText.getText().toString().equals("")) && (!mLandText.getText().toString().equals("")) && (!mRegiSpin.getSelectedItem().equals("")) && (!mPilotSpin.getSelectedItem().equals(""))) { ContentValues values = new ContentValues(); values.put(GliderLogTables.F_DATE, mDateText.getText().toString()); values.put(GliderLogTables.F_REGISTRATION, (String) mRegiSpin.getSelectedItem()); String ftype = ""; if (mTypeNorm.isChecked()) { ftype = ""; } if (mTypePass.isChecked()) { ftype = "PASS"; } if (mTypeDona.isChecked()) { ftype = "DONA"; } if (mTypeClub.isChecked()) { ftype = "CLUB"; } values.put(GliderLogTables.F_TYPE, ftype); values.put(GliderLogTables.F_INSTRUCTION, (mInstChck.isChecked()) ? "J" : "N"); String fPilo = (String) mPilotSpin.getSelectedItem(); values.put(GliderLogTables.F_PILOT, fPilo); String fPilo_id = ""; for (int i = 0; i < mPilotSpin.getCount(); i++) { String s = (String) mPilotSpin.getItemAtPosition(i); if (s.equalsIgnoreCase(fPilo)) { fPilo_id = MemberIndexList.get(i); } } values.put(GliderLogTables.F_PILOT_ID, fPilo_id); String fCoPi = (String) mCoPilotSpin.getSelectedItem(); values.put(GliderLogTables.F_COPILOT, fCoPi); String fCoPi_id = ""; for (int i = 0; i < mCoPilotSpin.getCount(); i++) { String s = (String) mCoPilotSpin.getItemAtPosition(i); if (s.equalsIgnoreCase(fCoPi)) { fCoPi_id = MemberIndexList.get(i); } } values.put(GliderLogTables.F_COPILOT_ID, fCoPi_id); values.put(GliderLogTables.F_STARTED, ""); values.put(GliderLogTables.F_LANDED, ""); values.put(GliderLogTables.F_DURATION, ""); String fLaun = ""; if (mLaunchWinch.isChecked()) { fLaun = "L"; } if (mLaunchTow.isChecked()) { fLaun = "S"; } if (mLaunchMotor.isChecked()) { fLaun = "M"; } values.put(GliderLogTables.F_LAUNCH, fLaun); values.put(GliderLogTables.F_SENT, "0"); values.put(GliderLogTables.F_ACK, "0"); values.put(GliderLogTables.F_NOTES, ""); // New flight flightUri = getContentResolver() .insert(FlightsContentProvider.CONTENT_URI_FLIGHT, values); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); } }); exitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { flg_save = true; setResult(RESULT_CANCELED); finish(); } }); timeSButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { time_mde = 10; // Creating a bundle object to pass currently set time to the fragment Bundle b = new Bundle(); if (!mStartText.getText().toString().isEmpty()) { String[] split = mStartText.getText().toString().split(":"); hour = Integer.parseInt(split[0]); minute = Integer.parseInt(split[1]); } else { final Calendar c = Calendar.getInstance(); hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE); } b.putInt("set_hour", hour); b.putInt("set_minute", minute); // Instantiating TimePickerDialogFragment & pass it' arguments TimePickerDialogFragment timePicker = new TimePickerDialogFragment(mHandler); timePicker.setArguments(b); // Getting fragment manger for this activity & start transaction FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.add(timePicker, "time_picker"); /** Opening the TimePicker fragment */ ft.commit(); } }); timeLButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { time_mde = 20; // Creating a bundle object to pass currently set time to the fragment Bundle b = new Bundle(); if (!mLandText.getText().toString().isEmpty()) { String[] split = mLandText.getText().toString().split(":"); hour = Integer.parseInt(split[0]); minute = Integer.parseInt(split[1]); } else { final Calendar c = Calendar.getInstance(); hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE); } b.putInt("set_hour", hour); b.putInt("set_minute", minute); // Instantiating TimePickerDialogFragment & pass it' arguments TimePickerDialogFragment timePicker = new TimePickerDialogFragment(mHandler); timePicker.setArguments(b); // Getting fragment manger for this activity & start transaction FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.add(timePicker, "time_picker"); /** Opening the TimePicker fragment */ ft.commit(); } }); clearSButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String S_T = mStartText.getText().toString(); if (S_T.isEmpty()) { final Calendar c = Calendar.getInstance(); //second = c.get(Calendar.SECOND); //mStartText.setText(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)) + ":" + Common.TwoDigits(c.get(Calendar.MINUTE))); mStartText.setText(new StringBuilder().append(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY))) .append(":").append(Common.TwoDigits(c.get(Calendar.MINUTE)))); } else { mStartText.setText(""); } } }); clearLButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String L_T = mLandText.getText().toString(); if (L_T.isEmpty()) { final Calendar c = Calendar.getInstance(); //second = c.get(Calendar.SECOND); //mLandText.setText(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)) + ":" + Common.TwoDigits(c.get(Calendar.MINUTE))); mLandText.setText(new StringBuilder().append(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY))) .append(":").append(Common.TwoDigits(c.get(Calendar.MINUTE)))); } else { mLandText.setText(""); } } }); mRegiSpin.setOnItemSelectedListener(new Custom0_OnItemSelectedListener()); mPilotSpin.setOnItemSelectedListener(new Custom1_OnItemSelectedListener()); gliderButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // get add_glider.xml view LayoutInflater li = LayoutInflater.from(edi_con); View promptsView = li.inflate(R.layout.add_glider, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(edi_con); // set add_glider.xml to alertdialog builder alertDialogBuilder.setView(promptsView); final EditText userInput1 = (EditText) promptsView.findViewById(R.id.editTextInput1); final EditText userInput2 = (EditText) promptsView.findViewById(R.id.editTextInput2); final CheckBox userInput3 = (CheckBox) promptsView.findViewById(R.id.editCheckInput3); final CheckBox userInput4 = (CheckBox) promptsView.findViewById(R.id.editCheckInput4); // set dialog message alertDialogBuilder.setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override @SuppressLint("DefaultLocale") public void onClick(DialogInterface dialog, int id) { // user input, convert to UC, add to glider list & spinner result = userInput1.getText().toString().toUpperCase(); if (GliderList.contains(result)) { makeToast("Invoer extra, deze kist bestaat reeds !"); result = null; dialog.cancel(); } else { GliderList.add(result); GliderCall.add(userInput2.getText().toString().toUpperCase()); GliderSeatsList.add(userInput3.isChecked() ? "2" : "1"); GliderPrivateList.add(userInput4.isChecked() ? "1" : "0"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>( FlightDetailActivity.this, android.R.layout.simple_spinner_item, GliderList); dataAdapter .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mRegiSpin.setAdapter(dataAdapter); // add to DB table try { ContentValues values = new ContentValues(); values.put(GliderLogTables.G_REGISTRATION, result); getContentResolver().insert(FlightsContentProvider.CONTENT_URI_GLIDER, values); values = null; } catch (Exception e) { Log.e("Exception", "Error: " + e.toString()); } } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { result = null; dialog.cancel(); } }); // create alert dialog & show it AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }); pilotButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // get prompts.xml view LayoutInflater li = LayoutInflater.from(edi_con); View promptsView = li.inflate(R.layout.add_member, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(edi_con); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder.setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override @SuppressLint("DefaultLocale") public void onClick(DialogInterface dialog, int id) { // get user input check for at least 2 // parts result = userInput.getText().toString(); if (MemberList.contains(result)) { makeToast("Invoer extra, deze naam bestaat reeds !"); result = null; dialog.cancel(); } else { String[] name = result.split(" "); if (name.length < 2) { makeToast( "Invoer extra, formaat => Voornaam (tussenvoegsel(s)) Achternaam is vereist !"); result = null; dialog.cancel(); } // add to member list & spinners MemberList.add(result); MemberIndexList.add("" + ini_id); MemberInstrList.add("0"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>( FlightDetailActivity.this, android.R.layout.simple_spinner_item, MemberList); dataAdapter .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPilotSpin.setAdapter(dataAdapter); mCoPilotSpin.setAdapter(dataAdapter); // add parts to DB table fields AddNewMember(name); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { result = null; dialog.cancel(); } }); // create alert dialog & show it AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }); setMode(); }
From source file:com.cloudant.todo.TodoActivity.java
public Dialog createNewTaskDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View v = this.getLayoutInflater().inflate(R.layout.dialog_new_task, null); final EditText description = (EditText) v.findViewById(R.id.new_task_desc); // Check description is present, if so add a task otherwise show an error DialogInterface.OnClickListener positiveClick = new DialogInterface.OnClickListener() { @Override/*from www . j a v a 2s .c om*/ public void onClick(DialogInterface dialog, int id) { if (description.getText().length() > 0) { createNewTask(description.getText().toString()); description.getText().clear(); } else { Toast.makeText(getApplicationContext(), R.string.task_not_created, Toast.LENGTH_LONG).show(); } } }; DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }; builder.setView(v).setTitle(R.string.new_task).setPositiveButton(R.string.create, positiveClick) .setNegativeButton(R.string.cancel, negativeClick); final AlertDialog d = builder.create(); // Enable "Create" button when the description has some characters final TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }; d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); description.addTextChangedListener(textWatcher); } }); return d; }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
public void refreshLabels(JSONObject jObject) { /* Button btn = new Button(this); btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height) )); btn.setTextSize(pixels);//from w w w .j ava 2s . co m btn.setText("Cat"); predictions.addView(btn); */ final List<RadioButton> buttons = new ArrayList<>(); String result = "I think it's: "; try { JSONArray jArray = jObject.getJSONArray("data"); for (int i = 0; i < jArray.length(); i++) { JSONObject prediction = jArray.getJSONObject(i); // Pulling items from the array int score = prediction.getInt("score"); if (score < Constants.minScoreThershold) { continue; } String label = prediction.getString("label"); result += "\"" + label + "\" : " + score + "% "; RadioButton radioButton = new RadioButton(EasyPaint.this); radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height))); radioButton.setTextSize(pixels5); radioButton.setText(label + " (" + score + "%)"); radioButton.setTag(label); //radioButton.set //predictions.addView(radioButton); radioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { saveButton.setTag(view.getTag()); feedbackType = ApiCallType.POSITIVE_FEEDBACK; } }); buttons.add(radioButton); } } catch (JSONException e) { e.printStackTrace(); } final RadioButton radioButton = new RadioButton(EasyPaint.this); radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height))); radioButton.setTextSize(pixels5); radioButton.setText(R.string.other_label); buttons.add(radioButton); radioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(EasyPaint.this); builder.setTitle(R.string.other_label); // Set up the input final EditText input = new EditText(EasyPaint.this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().length() > 0) { radioButton.setText(input.getText().toString()); saveButton.setTag(input.getText().toString()); feedbackType = ApiCallType.NEGATIVE_FEEDBACK; } else { EasyPaint.this.runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "You didn't specify a name, try again please", Toast.LENGTH_LONG) .show(); } }); saveButton.setTag(""); feedbackType = ApiCallType.POSITIVE_FEEDBACK; dialog.cancel(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { saveButton.setTag(""); feedbackType = ApiCallType.POSITIVE_FEEDBACK; dialog.cancel(); } }); builder.show(); } }); saveButton.setOnClickListener(otherLabelOnClickListener); toastMessage = result; EasyPaint.this.runOnUiThread(new Runnable() { public void run() { resetPredictionsView(predictions, false); Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG).show(); for (RadioButton r : buttons) { predictions.addView(r); } } }); }
From source file:color.kidpaint.com.kidpaintcolor.dialog.BrushPickerDialog.java
@TargetApi(11) @Override//from w w w. j av a 2 s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflator = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new CustomAlertDialogBuilder(mContext); // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // builder = new AlertDialog.Builder(mContext); // // } else { // builder = new AlertDialog.Builder(mContext, // AlertDialog.THEME_HOLO_DARK); // } builder.setTitle(R.string.stroke_title); View view = inflator.inflate(R.layout.dialog_stroke, null); ImageButton btn_circle = (ImageButton) view.findViewById(R.id.stroke_ibtn_circle); btn_circle.setOnClickListener(this); ImageButton btn_rect = (ImageButton) view.findViewById(R.id.stroke_ibtn_rect); btn_rect.setOnClickListener(this); mRbtnCircle = (RadioButton) view.findViewById(R.id.stroke_rbtn_circle); mRbtnCircle.setOnClickListener(this); mRbtnRect = (RadioButton) view.findViewById(R.id.stroke_rbtn_rect); mRbtnRect.setOnClickListener(this); mBrushWidthSeekBar = (SeekBar) view.findViewById(R.id.stroke_width_seek_bar); mBrushWidthSeekBar.setOnSeekBarChangeListener(new OnBrushChangedWidthSeekBarListener()); mBrushSizeText = (TextView) view.findViewById(R.id.stroke_width_width_text); builder.setView(view); builder.setNeutralButton(R.string.done, this); return builder.create(); }
From source file:com.code.android.vibevault.SearchScreen.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.nowPlaying: //Open playlist activity Intent np = new Intent(SearchScreen.this, NowPlayingScreen.class); //Intent np = new Intent(SearchScreen.this, HomeScreen.class); startActivity(np);//w w w . java 2s. c o m break; case R.id.recentShows: Intent rs = new Intent(SearchScreen.this, RecentShowsScreen.class); startActivity(rs); break; case R.id.scrollableDialog: AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Help!"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null); ((TextView) v.findViewById(R.id.DialogText)).setText(R.string.search_screen_help); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { } }); ad.setView(v); ad.show(); } return true; }