List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void show_license_dialog() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("Traffic Violation Database"); dialog.setMessage("Enter Plate #"); final EditText input = new EditText(this); dialog.setView(input); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from w ww .j a v a2s . c om*/ public void onClick(DialogInterface dialog, int which) { Cursor c = Utility.getTrafficViolations(HomeScreen.this, input.getText().toString().trim()); show_alert_title = "License Plate: " + input.getText().toString().trim().toUpperCase(); if (c != null && c.moveToFirst()) { show_alert_message = "State: " + c.getString(1) + CRLF; show_alert_message = show_alert_message + "Number of Violations: " + c.getString(5) + CRLF; show_alert_message = show_alert_message + "Last Violation: " + c.getString(4) + CRLF; show_alert_message = show_alert_message + "Days since last violation: " + Utility.getdayssincelastViolation(HomeScreen.this, input.getText().toString().trim()); } else show_alert_message = "No Recorded Violations"; showAlert(show_alert_title, show_alert_message, true); } }); //if no email to be sent then exit dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void show_username_dialog() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("User name: " + GTConstants.report_name); dialog.setMessage("Enter your name"); final EditText input = new EditText(this); dialog.setView(input); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/* w w w . j a va2s . c o m*/ public void onClick(DialogInterface dialog, int which) { //store in GTConstants for current use GTConstants.report_name = input.getText().toString().trim(); //store in preferences for later use SharedPreferences settings = getSharedPreferences("GTPrefs", 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("userName", GTConstants.report_name); editor.commit(); setuserBanner(); } }); //if no email to be sent then exit dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void send_media_via_email(final String type) { //only send email if "allowed" if (Utility.allowSend(HomeScreen.this)) { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("email the media?"); dialog.setMessage("Enter Email address"); final EditText input = new EditText(this); dialog.setView(input); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from w w w. ja v a2 s . c om*/ public void onClick(DialogInterface dialog, int which) { String emailAddress = input.getText().toString().trim(); File current_file = new File(file_name); //String attachment = GTConstants.receivefileFolder + current_file.getName(); ArrayList<String> mediaList = new ArrayList<String>(); mediaList.add(GTConstants.receivefileFolder + current_file.getName()); if (type.equalsIgnoreCase("audio")) Utility.send_email(HomeScreen.this, emailAddress, mediaList, "audio", "email from GT android App", "This email is being sent directly from the GuardTrax - Android App"); if (type.equalsIgnoreCase("photo")) Utility.send_email(HomeScreen.this, emailAddress, mediaList, "photo", "email from GT android App", "This email is being sent directly from the GuardTrax - Android App"); if (type.equalsIgnoreCase("video")) Utility.send_email(HomeScreen.this, emailAddress, mediaList, "video", "email from GT android App", "This email is being sent directly from the GuardTrax - Android App"); } }); //if no email to be sent then exit dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); } }
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void pingpicked(JSONObject json) { try {//from w ww. j a v a 2 s . co m int driverpicked = json.getInt("picked"); int drivercancelled = json.getInt("dcancel"); int starttime = json.getInt("datetime"); // /////////////////////////////// DRIVER CANCEL //////// if (drivercancelled == 1) { // //// DRIVER CANCEL LATE ///// if (starttime + 300 <= Query.getServerTime()) { handlerboolean = false; handler.removeCallbacks(r); AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?."); // //// DRIVER CANCEL LATE - NO REPORT LATE///// button_cancelJob_noquery(dcancelbuilder); // //// DRIVER CANCEL LATE - REPORT LATE ///// button_drivercancel_reportlate(dcancelbuilder); dcancelbuilder.show(); } else { // /////////////////////////////// DRIVER CANCEL NO ALERTS - // WITHIN TIME LIMIT/////////////// handlerboolean = false; handler.removeCallbacks(r); alertdialog_drivercancelintime(); } } if (driverpicked == 1) { // /////////////////////////////// CONFIRM PICK UP // /////////////////////////////////////////// handlerboolean = false; handler.removeCallbacks(r); AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this); final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup); final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite); final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown); final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite); LinearLayout layout = new LinearLayout(OnrouteScreen.this); layout.setOrientation(1); layout.setGravity(17); TextView tx1 = new TextView(OnrouteScreen.this); tx1.setText("Driver says you have been picked up"); tx1.setGravity(17); tx1.setTextSize(20); tx1.setTextColor(Color.WHITE); tx1.setPadding(10, 10, 10, 10); TextView tx2 = new TextView(OnrouteScreen.this); tx2.setText("Please rate your driver"); tx2.setGravity(17); tx2.setTextSize(16); LinearLayout imglayout = new LinearLayout(OnrouteScreen.this); imglayout.setOrientation(0); imglayout.setGravity(17); final ImageView ivup = new ImageView(OnrouteScreen.this); ivup.setImageDrawable(thumbsupwhite); ivup.setClickable(true); ivup.setPadding(0, 5, 30, 5); final ImageView ivdown = new ImageView(OnrouteScreen.this); ivdown.setImageDrawable(thumbsdownwhite); ivdown.setClickable(true); ivup.setPadding(30, 5, 0, 5); imglayout.addView(ivup); imglayout.addView(ivdown); layout.addView(tx1); layout.addView(tx2); layout.addView(imglayout); // /////////////////////////////// CONFIRM PICK UP - RATINGS // /////////////////////////////////////////// ivup.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsupboolean == false) { thumbsupboolean = true; thumbsdownboolean = false; ivup.setImageDrawable(thumbsup); ivdown.setImageDrawable(thumbsdownwhite); rating = 1; } else { thumbsupboolean = false; ivup.setImageDrawable(thumbsupwhite); rating = 0; } } }); ivdown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsdownboolean == false) { thumbsdownboolean = true; thumbsupboolean = false; ivdown.setImageDrawable(thumbsdown); ivup.setImageDrawable(thumbsupwhite); AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create(); alert.setMessage("Please pick one"); alert.setButton("No show", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -1; } }); alert.setButton2("Driver late", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -2; } }); alert.setButton3("Poor service", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -3; } }); alert.show(); } else { thumbsupboolean = false; ivdown.setImageDrawable(thumbsdownwhite); rating = 0; } } }); button_completed_finish(alert); alert.setView(layout); alert.create(); alert.show(); } else { } } catch (JSONException e) { } }
From source file:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new CustomAlertDialogBuilder(mContext); builder.setTitle(R.string.text_tool_dialog_title); final View view = inflater.inflate(R.layout.dialog_text_tool, null); mTextEditText = (EditText) view.findViewById(R.id.text_tool_dialog_input_text); mTextEditText.addTextChangedListener(new TextWatcher() { @Override/*from ww w. j a v a2s . c o m*/ public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String text = mTextEditText.getText().toString(); mOnTextToolDialogChangedListener.setText(text); mText = text; } }); mFontSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_font); ArrayAdapter<CharSequence> fontAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_font_array, android.R.layout.simple_spinner_item); fontAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mFontSpinner.setAdapter(fontAdapter); mFontSpinner.setBackgroundColor(Color.GRAY); mFontSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String font = parent.getItemAtPosition(position).toString(); mOnTextToolDialogChangedListener.setFont(font); mFontIndex = position; if (mFontSpinnerInitialized) hideKeyboard(); else mFontSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mUnderlinedToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_underlined); mUnderlinedToggleButton.setTextOn(Html .fromHtml("<u>" + getResources().getString(R.string.text_tool_dialog_underline_shortcut) + "</u>")); mUnderlinedToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean underlined = mUnderlinedToggleButton.isChecked(); mOnTextToolDialogChangedListener.setUnderlined(underlined); mUnderlined = underlined; hideKeyboard(); } }); mItalicToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_italic); mItalicToggleButton.setTextOn(Html .fromHtml("<i>" + getResources().getString(R.string.text_tool_dialog_italic_shortcut) + "</i>")); mItalicToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean italic = mItalicToggleButton.isChecked(); mOnTextToolDialogChangedListener.setItalic(italic); mItalic = italic; hideKeyboard(); } }); mBoldToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_bold); mBoldToggleButton.setTextOn( Html.fromHtml("<b>" + getResources().getString(R.string.text_tool_dialog_bold_shortcut) + "</b>")); mBoldToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean bold = mBoldToggleButton.isChecked(); mOnTextToolDialogChangedListener.setBold(bold); mBold = bold; hideKeyboard(); } }); mTextSizeSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_text_size); ArrayAdapter<CharSequence> textSizeAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_size_array, android.R.layout.simple_spinner_item); textSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTextSizeSpinner.setAdapter(textSizeAdapter); mTextSizeSpinner.setBackgroundColor(Color.GRAY); mTextSizeSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { int size = Integer.parseInt(parent.getItemAtPosition(position).toString()); mOnTextToolDialogChangedListener.setTextSize(size); mTextSizeIndex = position; if (mTextSizeSpinnerInitialized) hideKeyboard(); else mTextSizeSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setView(view); builder.setNeutralButton(R.string.done, this); Dialog textDialog = builder.create(); WindowManager.LayoutParams window_params = textDialog.getWindow().getAttributes(); textDialog.getWindow().setDimAmount(0.0f); textDialog.getWindow().setAttributes(window_params); return textDialog; }
From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Activity_WatchScanList.java
/** Called when the activity is first created. */ @Override/*ww w . j a v a 2 s . co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device_list); tv_status = (TextView) findViewById(R.id.textView_Status); deviceList_Display = new ArrayList<Map<String, String>>(); adapter_deviceList_Display = new SimpleAdapter(this, deviceList_Display, android.R.layout.simple_list_item_2, new String[] { "title", "desc" }, new int[] { android.R.id.text1, android.R.id.text2 }); ListView listView_Devices = (ListView) findViewById(R.id.listView_deviceList); listView_Devices.setAdapter(adapter_deviceList_Display); //Set the list to download the data for the selected device and display it. listView_Devices.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { if (!bDevicesInList || watchPcc == null) return; final CharSequence[] downloadOptions = { "All Activities", "New Activities", "Wait For New Activities" }; AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); builder.setTitle("Download..."); builder.setItems(downloadOptions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int downloadSelection) { antFsProgressDialog = new ProgressDialog(Activity_WatchScanList.this); antFsProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); antFsProgressDialog.setMessage("Sending Request..."); antFsProgressDialog.setCancelable(false); antFsProgressDialog.setIndeterminate(false); fitFileList = new ArrayList<FitFile>(); if (downloadSelection == 0) // download all { if (watchPcc.requestDownloadAllActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 1) // download new { if (watchPcc.requestDownloadNewActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 2) { boolean reqSubmitted = watchPcc.listenForNewActivities( deviceInfoArray[pos].getDeviceUUID(), new IDownloadActivitiesFinishedReceiver() { @Override public void onNewDownloadActivitiesFinished(AntFsRequestStatus status) { //Only received on cancel right now, only thing to do is cancel dialog, already taken care of below } }, new FileDownloadedReceiver() { @Override public void onNewFitFileDownloaded(FitFile downloadedFitFile) { super.onNewFitFileDownloaded(downloadedFitFile); //Now show each file as we get it List<FitFile> newActivityOnly = new ArrayList<FitFile>(fitFileList); fitFileList.clear(); final Dialog_WatchData dataDialog = new Dialog_WatchData( deviceInfoArray[pos], newActivityOnly); runOnUiThread(new Runnable() { @Override public void run() { dataDialog.show(getSupportFragmentManager(), "DeviceData"); } }); } }); //Once the listener is started we leave this dialog open until it is cancelled //Note: Because the listener is an asynchronous process, you do not need to block the UI like the sample app does with this, you can leave it invisible to the user if (reqSubmitted) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); LayoutInflater inflater = Activity_WatchScanList.this.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View detailsView = inflater.inflate(R.layout.dialog_progresswaiter, null); TextView textView_status = (TextView) detailsView .findViewById(R.id.textView_Status); textView_status.setText("Waiting for new activities on " + deviceInfoArray[pos].getDisplayName() + "..."); builder.setView(detailsView); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Let onCancelListener take care of business dialog.cancel(); } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (watchPcc != null) { watchPcc.cancelListenForNewActivities( deviceInfoArray[pos].getDeviceUUID()); } } }); AlertDialog waitDialog = builder.create(); waitDialog.show(); } } } }); AlertDialog alert = builder.create(); alert.show(); } }); resetPcc(); }
From source file:com.irccloud.android.activity.MainActivity.java
void editTopic() { ChannelsDataSource.Channel c = ChannelsDataSource.getInstance().getChannelForBuffer(buffer.bid); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); View view = getDialogTextPrompt(); TextView prompt = (TextView) view.findViewById(R.id.prompt); final EditText input = (EditText) view.findViewById(R.id.textInput); input.setText(c.topic_text);/*from w ww .j a va 2s . c o m*/ prompt.setVisibility(View.GONE); builder.setTitle("Channel Topic"); builder.setView(view); builder.setPositiveButton("Set Topic", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { conn.topic(buffer.cid, buffer.name, input.getText().toString()); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(this); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); }
From source file:com.app.viaje.viaje.MapsActivity.java
/** * @description :: Get posts./*from w w w.j a v a 2 s.c o m*/ */ private void getPosts() { final Query queryRef = dbRef.child(ViajeConstants.POSTS_KEY); queryRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { final Map<String, Post> td = new HashMap<String, Post>(); final ArrayList<Post> postValues = new ArrayList<>(td.values()); List<String> keys = new ArrayList<String>(td.keySet()); for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { Post post = postSnapshot.getValue(Post.class); td.put(postSnapshot.getKey(), post); double lat = post.getLat(); double lng = post.getLng(); String postContent = post.getText(); final String username = post.getUser().getUsername(); LatLng location = new LatLng(lat, lng); //User current location mMap.addMarker( new MarkerOptions().position(location).title("post").snippet(postSnapshot.getKey()) .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher))) .setTag(post); mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { if (marker.getTitle().contains("post")) { /** * Layout Inflater for the * alert dialog when a marker * has been click */ LayoutInflater inflater = getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.dialog_layout_comment, null, false); AlertDialog.Builder builder = new AlertDialog.Builder(MapsActivity.this); //Create StringBuilder to have a new line in every TextView StringBuilder sb = new StringBuilder(""); post_content = (TextView) dialogLayout.findViewById(R.id.postContent); date_time = (TextView) dialogLayout.findViewById(R.id.timestampID); postCommentContent = (TextView) dialogLayout .findViewById(R.id.commentContentID); postCommentedBy = (TextView) dialogLayout.findViewById(R.id.commentedByID); commentContentBody = (EditText) dialogLayout.findViewById(R.id.post); Post p = (Post) marker.getTag(); System.out.println(p); post_content.append(p.getText()); post_content.setPaintFlags( post_content.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); /** * Loop every entry of p.comments * inside the marker.getTag(). */ if (p.comments != null) { Iterator entries = p.comments.entrySet().iterator(); while (entries.hasNext()) { Map.Entry myEntry = (Map.Entry) entries.next(); Object key = myEntry.getKey(); Post.Comment value = (Post.Comment) myEntry.getValue(); String commenter = value.getUser().getUsername(); String dateTime = getDate(value.getTimestamp()); //String dateTime = new Date(value.getTimestamp()); sb.append(commenter + " on " + dateTime + "\n \t \t" + value.getText()); sb.append("\n \n"); postCommentedBy.setText(sb.toString()); } } //Button that submits a comment to a post. builder.setPositiveButton("Post Comment", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String comment = commentContentBody.getText().toString().trim(); /** * Function declaration that * submits a comment to the 'post' * at firebase database. */ if (comment.isEmpty()) { Snackbar snackbar = Snackbar.make(relativeLayout, "Comment must not be empty..", Snackbar.LENGTH_LONG); View sbView = snackbar.getView(); TextView textView = (TextView) sbView.findViewById( android.support.design.R.id.snackbar_text); textView.setTextColor(Color.RED); snackbar.show(); } else { postComment(comment, marker.getSnippet()); } } }); builder.setView(dialogLayout); builder.create().show(); } else if (marker.getTitle().contains("safezone")) { /** * If the marker type is safezone * then get the advertisement instead * of posts. */ final Safezone sz = (Safezone) marker.getTag(); /** * Layout Inflater for the * alert dialog when a marker * has been click */ LayoutInflater inflater = getLayoutInflater(); View adsDialog = inflater.inflate(R.layout.show_ads_info_window, null, false); AlertDialog.Builder builder = new AlertDialog.Builder(MapsActivity.this); ads_image = (ImageView) adsDialog.findViewById(R.id.ads); adText = (TextView) adsDialog.findViewById(R.id.adText); adTime = (TextView) adsDialog.findViewById(R.id.timestampID); adTitle = (TextView) adsDialog.findViewById(R.id.adTitle); shop_name = (TextView) adsDialog.findViewById(R.id.shop_name); String service_type = sz.getService_information_type(); String username = sz.getUsername(); System.out.print(username); if (service_type.contains("repair")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("hospital")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("towing")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("vulcanizing")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("gasoline")) { /** * @description Get ads of every * safezone */ getAds(sz); } builder.setView(adsDialog); builder.create().show(); } else { Snackbar snackbar = Snackbar.make(relativeLayout, "Current Location..", Snackbar.LENGTH_LONG); View sbView = snackbar.getView(); TextView textView = (TextView) sbView .findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor( ContextCompat.getColor(getApplicationContext(), R.color.app_color)); snackbar.show(); } return true; } }); } } //end if } @Override public void onCancelled(DatabaseError databaseError) { } }); }
From source file:com.if3games.chessonline.DroidFish.java
private final Dialog aboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String title = getString(R.string.app_name); WebView wv = new WebView(this); builder.setView(wv); InputStream is = getResources().openRawResource(R.raw.about); String data = Util.readFromStream(is); if (data == null) data = ""; try {//w w w . j a v a 2s .c om is.close(); } catch (IOException e1) { } wv.loadDataWithBaseURL(null, data, "text/html", "utf-8", null); try { PackageInfo pi = getPackageManager().getPackageInfo("com.if3games.chessonline", 0); title += " " + pi.versionName; } catch (NameNotFoundException e) { } builder.setTitle(title); AlertDialog alert = builder.create(); return alert; }
From source file:com.example.android.lightcontrol.MainActivity.java
private void light_configure() { LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.light_configure, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(this); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); final EditText change_light_name = (EditText) v.findViewById(R.id.editText3); Button change_name = (Button) v.findViewById(R.id.button3); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter);/*from w ww . ja v a 2 s . c o m*/ light_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { cursor.moveToPosition(i); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); change_name.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { helper.update(cursor.getInt(0), TABLE_NAME_DALISLAVEADDRESS, FEILD_NAME_DALI, String.valueOf(change_light_name.getText())); helper.close(); cursor.close(); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); adapter.notifyDataSetChanged(); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter); } }); dialog.setCancelable(false); dialog.setTitle(R.string.about_title); dialog.setView(v); dialog.setPositiveButton(R.string.ok_label_1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { updatespinner(); helper.close(); cursor.close(); } }); dialog.show(); }