List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:de.baumann.hhsmoodle.activities.Activity_count.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); toDo_title = sharedPref.getString("count_title", ""); String count_title = sharedPref.getString("count_content", ""); toDo_icon = sharedPref.getString("count_icon", ""); toDo_create = sharedPref.getString("count_create", ""); String todo_attachment = sharedPref.getString("count_attachment", ""); if (!sharedPref.getString("count_seqno", "").isEmpty()) { toDo_seqno = Integer.parseInt(sharedPref.getString("count_seqno", "")); }/*from w w w .j ava 2 s . com*/ setContentView(R.layout.activity_count); setTitle(toDo_title); final EditText etNewItem = (EditText) findViewById(R.id.etNewItem); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String itemText = etNewItem.getText().toString(); if (itemText.isEmpty()) { Snackbar.make(lvItems, R.string.todo_enter, Snackbar.LENGTH_LONG).show(); } else { itemsTitle.add(0, itemText); itemsCount.add(0, "0"); etNewItem.setText(""); writeItemsTitle(); writeItemsCount(); lvItems.post(new Runnable() { public void run() { lvItems.setSelection(lvItems.getCount() - 1); } }); adapter.notifyDataSetChanged(); } } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); helper_main.onStart(Activity_count.this); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } try { FileOutputStream fOut = new FileOutputStream(newFileTitle()); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(count_title); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } try { FileOutputStream fOut = new FileOutputStream(newFileCount()); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(todo_attachment); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } lvItems = (ListView) findViewById(R.id.lvItems); itemsTitle = new ArrayList<>(); readItemsTitle(); readItemsCount(); adapter = new CustomListAdapter(Activity_count.this, itemsTitle, itemsCount) { @NonNull @Override public View getView(final int position, View convertView, @NonNull ViewGroup parent) { View v = super.getView(position, convertView, parent); ImageButton ib_plus = (ImageButton) v.findViewById(R.id.but_plus); ImageButton ib_minus = (ImageButton) v.findViewById(R.id.but_minus); TextView tv = (TextView) v.findViewById(R.id.count_count); int count = Integer.parseInt(itemsCount.get(position)); if (count < 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_red)); } else if (count > 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_green)); } else if (count == 0) { tv.setTextColor(ContextCompat.getColor(Activity_count.this, R.color.color_grey)); } ib_plus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int a = Integer.parseInt(itemsCount.get(position)) + 1; String plus = String.valueOf(a); itemsCount.remove(position); itemsCount.add(position, plus); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); ib_minus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int a = Integer.parseInt(itemsCount.get(position)) - 1; String minus = String.valueOf(a); itemsCount.remove(position); itemsCount.add(position, minus); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); return v; } }; lvItems.setAdapter(adapter); lvItems.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(android.widget.AdapterView<?> parent, View view, final int position, long id) { final String title = itemsTitle.get(position); final String count = itemsCount.get(position); AlertDialog.Builder builder = new AlertDialog.Builder(Activity_count.this); View dialogView = View.inflate(Activity_count.this, R.layout.dialog_edit_text_singleline_count, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setText(title); builder.setView(dialogView); builder.setTitle(R.string.number_edit_entry); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); // Remove the item within array at position itemsTitle.remove(position); itemsCount.remove(position); itemsTitle.add(position, inputTag); itemsCount.add(position, count); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Activity_count.this, edit_title); } }); lvItems.setOnItemLongClickListener(new android.widget.AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(android.widget.AdapterView<?> parent, View view, final int position, long id) { final String title = itemsTitle.get(position); final String count = itemsCount.get(position); // Remove the item within array at position itemsTitle.remove(position); itemsCount.remove(position); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); Snackbar snackbar = Snackbar.make(lvItems, R.string.todo_removed, Snackbar.LENGTH_LONG) .setAction(R.string.todo_removed_back, new View.OnClickListener() { @Override public void onClick(View view) { itemsTitle.add(position, title); itemsCount.add(position, count); // Refresh the adapter adapter.notifyDataSetChanged(); // Return true consumes the long click event (marks it handled) writeItemsTitle(); writeItemsCount(); } }); snackbar.show(); return true; } }); }
From source file:com.example.sadashivsinha.mprosmart.Activities.AllVendors.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.fab_add: { Intent intent = new Intent(AllVendors.this, AddVendorsActivity.class); startActivity(intent);/*from w ww . ja va 2 s . co m*/ } break; case R.id.fab_search: { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Search Vendor by Vendor Name or ID !"); // Set an EditText view to get user input final EditText input = new EditText(this); input.setMaxLines(1); input.setImeOptions(EditorInfo.IME_ACTION_DONE); alert.setView(input); alert.setPositiveButton("Search", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (input.getText().toString().isEmpty()) { input.setError("Enter Search Field"); } else { Intent intent = new Intent(AllVendors.this, AllVendors.class); intent.putExtra("search", "yes"); intent.putExtra("searchText", input.getText().toString()); Log.d("SEARCH TEXT", input.getText().toString()); startActivity(intent); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(AllVendors.this, "Search cancelled .", Toast.LENGTH_SHORT).show(); } }); alert.show(); } break; case R.id.exportBtn: { //csv export int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion > android.os.Build.VERSION_CODES.LOLLIPOP) { if (ContextCompat.checkSelfPermission(AllVendors.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(AllVendors.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); } Environment.getExternalStorageState(); String vendorId = null, vendorName = null, vendorTypeId = null, decipline = null, taxID = null, license = null, companyName = null; int listSize = vendorList.size(); String cvsValues = "Vendor ID" + "," + "Vendor Name" + "," + "Vendor Type ID" + "," + "Discipline" + "Tax ID" + "," + "Licence" + "," + "Company Name" + "\n"; for (int i = 0; i < listSize; i++) { AllVendorList items = vendorList.get(i); vendorId = items.getVendor_id(); vendorName = items.getVendor_name(); vendorTypeId = items.getVendor_type(); decipline = items.getDiscipline(); taxID = items.getText_tax_id(); license = items.getText_licence_no(); companyName = items.getText_company_name(); switch (decipline) { case "1": decipline = "Electrical"; break; case "2": decipline = "Mechanical"; break; case "3": decipline = "Civil"; break; case "4": decipline = "Architectural"; break; } cvsValues = cvsValues + vendorId + "," + vendorName + "," + vendorTypeId + "," + decipline + taxID + "," + license + companyName + "\n"; } CsvCreateUtility.generateNoteOnSD(getApplicationContext(), "Vendors-data.csv", cvsValues); } else { Environment.getExternalStorageState(); String vendorId = null, vendorName = null, vendorTypeId = null, decipline = null, taxID = null, license = null, companyName = null; int listSize = vendorList.size(); String cvsValues = "Vendor ID" + "," + "Vendor Name" + "," + "Vendor Type ID" + "," + "Discipline" + "Tax ID" + "," + "Licence" + "," + "Company Name" + "\n"; for (int i = 0; i < listSize; i++) { AllVendorList items = vendorList.get(i); vendorId = items.getVendor_id(); vendorName = items.getVendor_name(); vendorTypeId = items.getVendor_type(); decipline = items.getDiscipline(); taxID = items.getText_tax_id(); license = items.getText_licence_no(); companyName = items.getText_company_name(); switch (decipline) { case "1": decipline = "Electrical"; break; case "2": decipline = "Mechanical"; break; case "3": decipline = "Civil"; break; case "4": decipline = "Architectural"; break; } cvsValues = cvsValues + vendorId + "," + vendorName + "," + vendorTypeId + "," + decipline + taxID + "," + license + companyName + "\n"; } CsvCreateUtility.generateNoteOnSD(getApplicationContext(), "Vendors-data.csv", cvsValues); } } break; } }
From source file:com.dsi.ant.antplus.pluginsampler.geocache.Dialog_GeoProgramDevice.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Program Device " + deviceData.deviceId); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); View detailsView = inflater.inflate(R.layout.dialog_geocache_programdevice, null); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(detailsView); // Add action buttons //Note we override the positive button in show() below so we can prevent it from closing builder.setPositiveButton("Begin Programing", null); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override//from w w w. j a v a2 s. c o m public void onClick(DialogInterface dialog, int which) { //Let dialog dismiss } }); checkBox_EnableIdString = (CheckBox) detailsView.findViewById(R.id.checkBox_EnableIdentifcationString); checkBox_EnablePIN = (CheckBox) detailsView.findViewById(R.id.checkBox_EnablePIN); checkBox_EnableLatitude = (CheckBox) detailsView.findViewById(R.id.checkBox_EnableLatitude); checkBox_EnableLongitude = (CheckBox) detailsView.findViewById(R.id.checkBox_EnableLongitude); checkBox_EnableHintString = (CheckBox) detailsView.findViewById(R.id.checkBox_EnableHintString); checkBox_EnableLastVisit = (CheckBox) detailsView.findViewById(R.id.checkBox_EnableLastVisitInfo); final TextView textView_NumVisitsTitle = (TextView) detailsView .findViewById(R.id.textView_NumberOfVisitsTitle); final TextView textView_LastVisitDateTitle = (TextView) detailsView .findViewById(R.id.textView_LastVisitDateTitle); final TextView textView_LastVisitTimeTitle = (TextView) detailsView .findViewById(R.id.textView_LastVisitTimeTitle); editText_IdString = (EditText) detailsView.findViewById(R.id.editText_IdentificationString); editText_PIN = (EditText) detailsView.findViewById(R.id.editText_PIN); editText_Latitude = (EditText) detailsView.findViewById(R.id.editText_Latitude); editText_Longitude = (EditText) detailsView.findViewById(R.id.editText_Longitude); editText_HintString = (EditText) detailsView.findViewById(R.id.editText_HintString); editText_NumVisits = (EditText) detailsView.findViewById(R.id.editText_NumberOfVisits); textView_LastVisitDate = (TextView) detailsView.findViewById(R.id.textView_LastVisitDate); textView_LastVisitTime = (TextView) detailsView.findViewById(R.id.textView_LastVisitTime); radioButton_ClearExisitingData = (RadioButton) detailsView.findViewById(R.id.radioButton_ClearExistingData); //Hook up checkboxes to enable/disable fields checkBox_EnableIdString.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editText_IdString.setEnabled(isChecked); if (isChecked && editText_IdString.getText().length() == 0) editText_IdString.setText("ID STR"); } }); checkBox_EnablePIN.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editText_PIN.setEnabled(isChecked); if (isChecked && editText_PIN.getText().length() == 0) editText_PIN.setText("123456"); } }); checkBox_EnableLatitude.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editText_Latitude.setEnabled(isChecked); if (isChecked && editText_Latitude.getText().length() == 0) editText_Latitude.setText("-40.1"); } }); checkBox_EnableLongitude.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editText_Longitude.setEnabled(isChecked); if (isChecked && editText_Longitude.getText().length() == 0) editText_Longitude.setText("-20.1"); } }); checkBox_EnableHintString.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editText_HintString.setEnabled(isChecked); if (isChecked && editText_HintString.getText().length() == 0) editText_HintString.setText("Hint string."); } }); checkBox_EnableLastVisit.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { textView_NumVisitsTitle.setEnabled(isChecked); textView_LastVisitDateTitle.setEnabled(isChecked); textView_LastVisitTimeTitle.setEnabled(isChecked); editText_NumVisits.setEnabled(isChecked); textView_LastVisitDate.setEnabled(isChecked); textView_LastVisitTime.setEnabled(isChecked); if (isChecked) { if (editText_NumVisits.length() == 0) editText_NumVisits.setText("0"); if (textView_LastVisitDate.length() == 0) textView_LastVisitDate.setText("dd/mmm/yyyy"); if (textView_LastVisitTime.length() == 0) textView_LastVisitDate.setText("hh:mm"); } } }); //Set data editText_IdString.setText(String.valueOf(deviceData.programmableData.identificationString)); editText_PIN.setText(String.valueOf(deviceData.programmableData.PIN)); if (deviceData.programmableData.latitude != null) editText_Latitude.setText( String.valueOf(deviceData.programmableData.latitude.setScale(5, BigDecimal.ROUND_HALF_UP))); else editText_Latitude.setText(""); if (deviceData.programmableData.longitude != null) editText_Longitude.setText( String.valueOf(deviceData.programmableData.longitude.setScale(5, BigDecimal.ROUND_HALF_UP))); else editText_Longitude.setText(""); if (deviceData.programmableData.hintString != null) editText_HintString.setText(String.valueOf(deviceData.programmableData.hintString)); else editText_HintString.setText(""); if (deviceData.programmableData.numberOfVisits != null) editText_NumVisits.setText(String.valueOf(deviceData.programmableData.numberOfVisits)); else editText_NumVisits.setText(""); if (deviceData.programmableData.lastVisitTimestamp != null) { currentDisplayDatetime = deviceData.programmableData.lastVisitTimestamp; updateDateAndTime(); } else { textView_LastVisitDate.setText(""); textView_LastVisitTime.setText(""); } //Hook up date and time fields to pickers textView_LastVisitDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentDisplayDatetime == null) currentDisplayDatetime = new GregorianCalendar(TimeZone.getTimeZone("UTC")); DatePickerDialog d = new DatePickerDialog(getActivity(), new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { currentDisplayDatetime.set(year, monthOfYear, dayOfMonth); updateDateAndTime(); } }, currentDisplayDatetime.get(Calendar.YEAR), currentDisplayDatetime.get(Calendar.MONTH), currentDisplayDatetime.get(Calendar.DAY_OF_MONTH)); d.show(); } }); textView_LastVisitTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentDisplayDatetime == null) currentDisplayDatetime = new GregorianCalendar(TimeZone.getTimeZone("UTC")); TimePickerDialog d = new TimePickerDialog(getActivity(), new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { currentDisplayDatetime.set(Calendar.HOUR_OF_DAY, hourOfDay); currentDisplayDatetime.set(Calendar.MINUTE, minute); updateDateAndTime(); } }, currentDisplayDatetime.get(Calendar.HOUR_OF_DAY), currentDisplayDatetime.get(Calendar.MINUTE), false); d.show(); } }); return builder.create(); }
From source file:com.findme.adapter.ImageListAdapter.java
@Override public View getView(int position, View view, ViewGroup viewGroup) { // We only create the view if its needed if (view == null) { view = inflator.inflate(R.layout.image_list_child, null); // Set the click listener for the checkbox // view.findViewById(R.id.isSelectedCheckBox).setOnClickListener(this); } else// w w w . j av a 2 s .com return view; final JSONObject personInfo = (JSONObject) getItem(position); String imgUrl = null; try { imgUrl = prefix + personInfo.getJSONArray("images").getString(0); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Log.d("image", imgUrl); count++; Log.d("Result", String.valueOf(count)); final ImageButton img = (ImageButton) view.findViewById(R.id.appImageView1); URL url; Bitmap bmp = null; (new DownloadImageTask(img)).execute(imgUrl); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(mainAct); View view = LayoutInflater.from(mainAct).inflate(R.layout.popup_layout, null); ImageView image = (ImageView) view.findViewById(R.id.resultDialogImg); /** * Not sure about the license of PhotoViewAttacher * TODO : look into the license of this and decide whether to use it or not. */ image.setImageDrawable(img.getDrawable()); PhotoViewAttacher mAttacher = new PhotoViewAttacher(image); mAttacher.update(); //builder.setIcon(mainAct.getResources().getDrawable(mainAct.getResources().getIdentifier(app.getImage(), "drawable", mainAct.getPackageName()))); builder.setView(view); builder.setPositiveButton(R.string.match_found, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { (new AsyncHttpPostTask(prefix)).execute(personInfo.getString("personname")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // User clicked OK. Start a new game. dialog.dismiss(); } }); builder.create().show(); } }); return view; }
From source file:com.example.emachine.FXcalcActivity.java
private void textDialog(String title, String dialogtext) { // get prompts.xml view String returnString = ""; hideKeyboard();/*from w ww.j a v a2s . co m*/ LayoutInflater li = LayoutInflater.from(getBaseContext()); View promptsView = li.inflate(R.layout.alertdialog_sysmsg_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput); TextView tv_custom_dialog_title = (TextView) promptsView.findViewById(R.id.tv_custom_dialog_title); TextView tv_text_dialog = (TextView) promptsView.findViewById(R.id.tv_text_dialog); // ImageView iv_image = (ImageView) promptsView.findViewById(R.id.iv_image); tv_custom_dialog_title.setText(title); tv_text_dialog.setText(dialogtext); // set dialog message alertDialogBuilder.setCancelable(true).setPositiveButton("Good one", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // EspressoMachine_AlertDialogButtonClicked("Good one", TAG); alert("You have chosen, Wisely. "); Intent intent = new Intent(getBaseContext(), FieldOfFieldsActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { startActivity(intent); } dialog.cancel(); } }) // public void onClick(DialogInterface dialog, int id) { EspressoAlertDialogButtonClicked(); // // get user input and set it to result // // edit text // if (!userInput.getText().toString().equals("demo") && userInput.getText().toString().equals(getprefPassword(getBaseContext()))) { // // } else { alert("Password incorrect");} // // } // }) // .setNeutralButton("Gallery", new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int id) { EspressoAlertDialogButtonClicked(); // // get user input and set it to result // // edit text // if (!userInput.getText().toString().equals("demo") && userInput.getText().toString().equals(getprefPassword(getBaseContext()))) { // // } else { alert("Password incorrect");} // // } // }) .setNegativeButton("BAD QA", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // EspressoMachine_AlertDialogButtonClicked("Bad QA", TAG); alert("You have chosen, Poorly! "); dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button negativeButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE); Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE); Button neutralButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEUTRAL); // this not working because multiplying white background (e.g. Holo Light) has no effect //negativeButton.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY); // final Drawable negativeButtonDrawable = getResources().getDrawable(R.color.btn_background); final Drawable positiveButtonDrawable = getResources().getDrawable(R.color.btn_background); // final Drawable neutralButtonDrawable = getResources().getDrawable(R.color.btn_background); // negativeButton.setBackground(negativeButtonDrawable); // positiveButton.setBackground(positiveButtonDrawable); // neutralButton.setBackground(neutralButtonDrawable); } }); }
From source file:com.rsltc.profiledata.main.MainActivity.java
private void showSaveDialog(final List<JSONObject> jsonObjectList) { AlertDialog.Builder builder = new AlertDialog.Builder(thisActivity); builder.setTitle("Dataset title"); final EditText input = new EditText(thisActivity); input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override// ww w.j av a 2 s. c o m public void onClick(DialogInterface dialog, int which) { final String m_Text = input.getText().toString(); Runnable r = new Runnable() { @Override public void run() { exportFile(jsonObjectList, m_Text); } }; Thread t = new Thread(r); t.start(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
public void openDialog() { // get prompts.xml view LayoutInflater li = LayoutInflater.from(GetAllVehicalDetails.this); View promptsView = li.inflate(R.layout.prompt, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(GetAllVehicalDetails.this); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); alertDialogBuilder.setTitle("Why you want to stop this"); final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to result // edit text //result.setText(userInput.getText()); if (!userInput.getText().toString().trim().isEmpty()) { reason = userInput.getText().toString().trim(); getUserData(reason);/* w w w .ja v a 2 s . co m*/ } else { Toast.makeText(GetAllVehicalDetails.this, "Please fill your reason", Toast.LENGTH_LONG).show(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); }
From source file:com.autburst.picture.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { final Dialog dialog; final Context mContext = this; switch (id) { case DIALOG_CREATE_ALBUM_ID: AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle(R.string.new_gallery); View view = getLayoutInflater().inflate(R.layout.create_album, null); final EditText edit = (EditText) view.findViewById(R.id.albumNameEditText); final RadioGroup rg = (RadioGroup) view.findViewById(R.id.formatRadioGroup); builder2.setView(view); builder2.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String name = edit.getText().toString(); Log.d(TAG, "Entered name: " + name); // base64 encode string String encodedName = new String(Base64.encodeBase64(name.getBytes())); Log.d(TAG, "base64 encoded name: " + encodedName); // check if album with the same name already exist if (Utilities.existsAlbumName(encodedName)) { // fehler showDialog(DIALOG_ALBUM_NAME_ALREADY_EXIST); return; }/* w ww .j a va2 s . c om*/ // create folder Utilities.getAlbumDirectory(encodedName); // get format int checkedRadioButtonId = rg.getCheckedRadioButtonId(); final Boolean portrait; if (checkedRadioButtonId == R.id.portraitRB) portrait = true; else portrait = false; SharedPreferences settings = getSharedPreferences(Utilities.PIC_STORE, 0); Editor edit2 = settings.edit(); edit2.putBoolean(encodedName + ".portrait", portrait); edit2.putFloat(encodedName + ".frameRate", Utilities.MEDIUM_FRAME_RATE); edit2.commit(); Log.d(TAG, "portrait: " + portrait + " settingsname: " + encodedName + ".portrait frameRate: " + Utilities.MEDIUM_FRAME_RATE); // reset editView edit.setText(""); // update table adapter.add(encodedName); adapter.sort(Utilities.getAlbumNameComparator()); adapter.notifyDataSetChanged(); dialog.dismiss(); controller.transformGUI(MainActivityController.CREATED_ALBUM); } }); builder2.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); // reset editView edit.setText(""); // showDialog(DIALOG_CREATE_ALBUM_ID); } }); AlertDialog create = builder2.create(); dialog = create; break; case DIALOG_ALBUM_NAME_ALREADY_EXIST: AlertDialog.Builder builder3 = new AlertDialog.Builder(this); builder3.setTitle(R.string.warning); builder3.setMessage(R.string.gallery_exists); builder3.setNegativeButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // dialog.dismiss(); showDialog(DIALOG_CREATE_ALBUM_ID); } }); dialog = builder3.create(); break; default: dialog = null; } return dialog; }
From source file:org.telegram.ui.myLocationSettingsActivity.java
@Override public View createView(LayoutInflater inflater) { if (fragmentView == null) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle("My Places"); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from ww w . j a v a2s . c o m public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(getParentActivity()); fragmentView = new FrameLayout(getParentActivity()); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(0xfff0f0f0); ListView listView = new ListView(getParentActivity()); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == homeRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Home"); final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(50, 30); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); input.setLayoutParams(lparams); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationHome = new getCoordinates().execute(city).get(); String latHome = locationHome.getString("lat"); String lonHome = locationHome.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latHome", latHome); editor.putString("longHome", lonHome); editor.commit(); Log.i(TAG, "fine! " + lonHome); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == workRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Work"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationWork = new getCoordinates().execute(city).get(); String latWork = locationWork.getString("lat"); String lonWork = locationWork.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latWork", latWork); editor.putString("longWork", lonWork); editor.commit(); Log.i(TAG, "fine! " + latWork); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == entertainmentRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Entertainment"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationEntertainment = new getCoordinates().execute(city).get(); String latEntertainment = locationEntertainment.getString("lat"); String lonEntertainment = locationEntertainment.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latEntertainment", latEntertainment); editor.putString("longEntertainment", lonEntertainment); editor.commit(); Log.i(TAG, "fine! " + latEntertainment); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } //TODO find a solution for commuteRow as well!! } }); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
From source file:com.bt.heliniumstudentapp.UpdateClass.java
protected UpdateClass(final Activity context, boolean settings) { UpdateClass.context = context;/*from w w w. jav a2 s. co m*/ this.settings = settings; final AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(context, MainActivity.themeDialog)); updateDialogBuilder.setTitle(R.string.update_checking); updateDialogBuilder.setNegativeButton(R.string.cancel, null); updateDialogBuilder.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //FIXME Come on, don't do this up here ActivityCompat.requestPermissions(context, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 1); //TODO See warning //FIXME Great, now everything is protected... } }); updateDialogBuilder.setView(R.layout.dialog_update); updateDialog = updateDialogBuilder.create(); updateDialog.setCanceledOnTouchOutside(true); if (settings) { updateDialog.show(); updateDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); updateDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setTextColor(ContextCompat.getColor(context, MainActivity.accentPrimaryColor)); updateDialog.getButton(AlertDialog.BUTTON_NEGATIVE) .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor)); } }