List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display the list of browser history./*from www .ja v a 2 s.c om*/ * * @param context */ public static void displayBrowserHistory(final Launcher context) { final ArrayList<BookmarkInfo> bookmarks = loadBrowserHistory(context); if (bookmarks.size() > 0) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.bookmarks_list); ListView listView = (ListView) dialog.findViewById(R.id.list); listView.setAdapter(new BookmarkAdapter(context, bookmarks)); listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bookmark.getUrl())); context.startActivity(browserIntent); context.showCover(false); dialog.dismiss(); Analytics.logEvent(Analytics.INVOKE_BOOKMARK); } }); listView.setDrawingCacheEnabled(true); listView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_BOOKMARKS); } else { displayAlert(context, context.getString(R.string.dialog_no_browser_history)); } }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityJourney.java
/** * sends a message to the driver of a journey *//*from ww w . j a v a 2s.c om*/ private void sendMessageToDriver() { final Dialog customDialog = new Dialog(this); customDialog.setContentView(R.layout.custom_dialog_layout); customDialog.setTitle("Message"); final List<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("Everyone"); if (!getApp().getSelectedJourney().getDriver().equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getDriver().getFullName()); } for (int i = 0; i < getApp().getSelectedJourney().getHitchhikers().size(); i++) { if (!getApp().getSelectedJourney().getHitchhikers().get(i).equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getHitchhikers().get(i).getFullName()); } } final Spinner spinner = (Spinner) customDialog.findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivityJourney.this, android.R.layout.simple_spinner_item, spinnerArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); ImageView sendBtn = (ImageView) customDialog.findViewById(R.id.sendBtn); final EditText input = (EditText) customDialog.findViewById(R.id.input); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { User mid = getApp().getUser(); if (spinner.getSelectedItem().toString().equals("Everyone")) { if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { List<User> userList = new ArrayList<User>(); userList.add(getApp().getSelectedJourney().getDriver()); for (int k = 0; k < getApp().getSelectedJourney().getHitchhikers().size(); k++) { userList.add(getApp().getSelectedJourney().getHitchhikers().get(k)); } userList.remove(getApp().getUser()); for (int k = 0; k < userList.size(); k++) { sendMessage(userList.get(k), input); } Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } else { for (int j = 0; j < getApp().getSelectedJourney().getHitchhikers().size(); j++) { if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getHitchhikers().get(j).getFullName())) { mid = getApp().getSelectedJourney().getHitchhikers().get(j); } } if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getDriver().getFullName())) { mid = getApp().getSelectedJourney().getDriver(); } if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { sendMessage(mid, input); Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } } }); customDialog.show(); }
From source file:com.openerp.addons.idea.product.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.Dash_Board: Dash_Board detail = new Dash_Board(); FragmentListener frag = (FragmentListener) getActivity(); frag.startDetailFragment(detail); return true; case R.id.Search_product: final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.product_search_custom_dialog); // dialog.setTitle("Product Search"); dialog.setOnCancelListener(new OnCancelListener() { @Override/*w w w . jav a 2 s . c om*/ public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); AutoCompleteTextView autotext = (AutoCompleteTextView) dialog .findViewById(R.id.autoCompleteTextView_product_search); final ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, OEHelper.datatemplate); TextView txv = (TextView) dialog.findViewById(R.id.textView1); Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf"); autotext.setTypeface(font, Typeface.BOLD); autotext.setAdapter(adapter); txv.setTypeface(font, Typeface.BOLD); autotext.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String name = adapter.getItem(arg2).toString(); callmethod_for_position_productdetail(OEHelper.datatemplate.indexOf(name)); dialog.dismiss(); } }); dialog.show(); return true; } return true; }
From source file:com.procleus.brime.ui.LabelsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment ((MainActivity) getActivity()).setActionBarTitle("Labels"); ((MainActivity) getActivity()).showFloatingActionButton(true); final View v = inflater.inflate(R.layout.labels_gragment, container, false); final NotesDbHelperOld tn = new NotesDbHelperOld(getActivity()); labelsRetrieved = new ArrayList<String>(); labelsRetrieved = tn.retrieveLabel(); listView = (ListView) v.findViewById(R.id.listLabel); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter);/*from ww w . jav a 2 s . co m*/ ImageButton addLabelBtn = (ImageButton) v.findViewById(R.id.addLabelBtn); addLabelBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { addLabelFunc(v, tn); } }); /*/WORK OF LONG ITEM CLICK LISTENER*/ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) { final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_label); dialog.show(); final Button negative = (Button) dialog.findViewById(R.id.btn_no_label); final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label); negative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("brinjal", "Yes"); tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position))); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter); dialog.dismiss(); } }); return true; } }); return v; }
From source file:com.mimp.fragment.institucion.PlanTrabajoPage.java
public void btnAgregar() { final Dialog dialog = new Dialog(this.getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); //dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_plan_trabajo); TextView lblResponsable = (TextView) dialog.findViewById(R.id.lblResponsable); lblResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblResponsable.getTextSize() + SizeText); TextView lblDResponsable = (TextView) dialog.findViewById(R.id.lblDResponsable); lblDResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblDResponsable.getTextSize() + SizeText); TextView lblObejtivo = (TextView) dialog.findViewById(R.id.lblObejtivo); lblObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblObejtivo.getTextSize() + SizeText); TextView lblMeta = (TextView) dialog.findViewById(R.id.lblMeta); lblMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblMeta.getTextSize() + SizeText); TextView lblActividad = (TextView) dialog.findViewById(R.id.lblActividad); lblActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblActividad.getTextSize() + SizeText); TextView lblCronograma = (TextView) dialog.findViewById(R.id.lblCronograma); lblCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblCronograma.getTextSize() + SizeText); final EditText txtObejtivo = (EditText) dialog.findViewById(R.id.txtObejtivo); txtObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtObejtivo.getTextSize() + SizeText); txtObejtivo.setText(""); final EditText txtActividad = (EditText) dialog.findViewById(R.id.txtActividad); txtActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtActividad.getTextSize() + SizeText); txtActividad.setText(""); final EditText txtCronograma = (EditText) dialog.findViewById(R.id.txtCronograma); txtCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtCronograma.getTextSize() + SizeText); txtCronograma.setText(""); final EditText txtMeta = (EditText) dialog.findViewById(R.id.txtMeta); txtMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtMeta.getTextSize() + SizeText); txtMeta.setText(""); final EditText txtResponsable = (EditText) dialog.findViewById(R.id.txtResponsable); txtResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtResponsable.getTextSize() + SizeText); txtResponsable.setText(""); Button btnAgregar = (Button) dialog.findViewById(R.id.btnAgregar); btnAgregar.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2 s .co m public void onClick(View v) { clsPlanTrabajo entidad = new clsPlanTrabajo(); entidad.setActividad(txtActividad.getText().toString()); entidad.setCronograma(txtCronograma.getText().toString()); entidad.setMeta(txtMeta.getText().toString()); entidad.setObejtivo(txtObejtivo.getText().toString()); entidad.setResponsable(txtResponsable.getText().toString()); list.add(entidad); getListaPlanTrabajo(); dialog.dismiss(); } }); dialog.show(); }
From source file:com.procleus.brime.ui.LabelsFragment.java
@Override public void onResume() { super.onResume(); NotesDbHelperOld tn = new NotesDbHelperOld(getContext()); labelsRetrieved = tn.retrieveLabel(); listView = (ListView) getView().findViewById(R.id.listLabel); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter);//from w w w.j av a2 s.c o m listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) { final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_label); dialog.show(); final Button negative = (Button) dialog.findViewById(R.id.btn_no_label); final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label); /*/This is Database Spinner Retreival*/ /* Spinner getting Data from dataBase*/ negative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("brinjalResume", "Yes"); NotesDbHelperOld tn = new NotesDbHelperOld(getActivity()); tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position))); labelsRetrieved = tn.retrieveLabel(); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, labelsRetrieved); listView.setAdapter(arrayAdapter); dialog.dismiss(); } }); return true; } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(), "Inside in label" + ":" + String.valueOf(parent.getItemAtPosition(position)), Toast.LENGTH_SHORT).show(); Intent i = new Intent(getActivity(), LabelOpenActivity.class); i.putExtra("label", String.valueOf(parent.getItemAtPosition(position))); startActivity(i); } }); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display a grid of all installed apps + virtual apps. Allow user to launch * apps.//from w ww . ja v a 2s.c o m * * @param context * @param applications */ public static void displayAllApps(final Launcher context, final ArrayList<ApplicationInfo> applications) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.apps_grid); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, false))); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); itemInfo.invoke(context); context.showCover(false); dialog.dismiss(); if (itemInfo instanceof ApplicationInfo) { ApplicationInfo applicationInfo = (ApplicationInfo) itemInfo; RecentAppsTable.persistRecentApp(context, applicationInfo); } } }); gridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> gridView, View view, int pos, long arg3) { ItemInfo itemInfo = (ItemInfo) gridView.getAdapter().getItem(pos); if (itemInfo instanceof ApplicationInfo) { Uri packageURI = Uri.parse("package:" + itemInfo.getIntent().getComponent().getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(uninstallIntent); context.showCover(false); dialog.dismiss(); Analytics.logEvent(Analytics.UNINSTALL_APP); } return false; } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ALL_APPS); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display the list of browser bookmarks. Allow user to load bookmarked web * site.//from ww w. j a va 2s.c o m * * @param context */ public static void displayBookmarks(final Launcher context) { final ArrayList<BookmarkInfo> bookmarks = loadBookmarks(context); if (bookmarks.size() > 0) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.bookmarks_list); ListView listView = (ListView) dialog.findViewById(R.id.list); Collections.sort(bookmarks, new Comparator<BookmarkInfo>() { @Override public int compare(BookmarkInfo lhs, BookmarkInfo rhs) { return lhs.getTitle().toLowerCase().compareTo(rhs.getTitle().toLowerCase()); } }); listView.setAdapter(new BookmarkAdapter(context, bookmarks)); listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bookmark.getUrl())); context.startActivity(browserIntent); context.showCover(false); dialog.dismiss(); Analytics.logEvent(Analytics.INVOKE_BOOKMARK); } }); listView.setDrawingCacheEnabled(true); listView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_BOOKMARKS); } else { displayAlert(context, context.getString(R.string.dialog_no_browser_bookmarks)); } }
From source file:edu.berkeley.boinc.ProjectDetailsFragment.java
private void showConfirmationDialog(final int operation) { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_confirm); Button confirm = (Button) dialog.findViewById(R.id.confirm); TextView tvTitle = (TextView) dialog.findViewById(R.id.title); TextView tvMessage = (TextView) dialog.findViewById(R.id.message); // operation dependend texts if (operation == RpcClient.PROJECT_DETACH) { tvTitle.setText(R.string.projects_confirm_detach_title); tvMessage.setText(getString(R.string.projects_confirm_detach_message) + " " + project.project_name + " " + getString(R.string.projects_confirm_detach_message2)); confirm.setText(R.string.projects_confirm_detach_confirm); } else if (operation == RpcClient.PROJECT_RESET) { tvTitle.setText(R.string.projects_confirm_reset_title); tvMessage.setText(getString(R.string.projects_confirm_reset_message) + " " + project.project_name + getString(R.string.projects_confirm_reset_message2)); confirm.setText(R.string.projects_confirm_reset_confirm); }//from w ww . j a v a2 s . c o m confirm.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new ProjectOperationAsync().execute(operation); dialog.dismiss(); } }); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.hacktx.android.activities.EventDetailActivity.java
private void setupCards() { final CardView rateEventCard = (CardView) findViewById(R.id.rateEventCard); View.OnClickListener feedbackOnClickListener = new View.OnClickListener() { @Override/* www . ja v a 2 s . c o m*/ public void onClick(View v) { if (!UserStateStore.getFeedbackSubmitted(EventDetailActivity.this, event.getId())) { final Dialog dialog = new Dialog(EventDetailActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_feedback); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(params); dialog.show(); final RatingBar ratingBar = (RatingBar) dialog.findViewById(R.id.feedbackDialogRatingBar); dialog.findViewById(R.id.feedbackDialogCancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mMetricsManager.logEvent(R.string.analytics_event_feedback_cancel, null); dialog.dismiss(); } }); dialog.findViewById(R.id.feedbackDialogSubmit).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { HackTxService hackTxService = HackTxClient.getInstance().getApiService(); hackTxService.sendFeedback(event.getId(), (int) ratingBar.getRating(), new Callback<EventFeedback>() { @Override public void success(EventFeedback feedback, Response response) { mMetricsManager.logEvent(R.string.analytics_event_feedback_submit, null); UserStateStore.setFeedbackSubmitted(EventDetailActivity.this, event.getId(), true); findViewById(R.id.rateEventCard).setVisibility(View.GONE); dialog.dismiss(); Snackbar.make(findViewById(android.R.id.content), R.string.event_feedback_submitted, Snackbar.LENGTH_SHORT) .show(); } @Override public void failure(RetrofitError error) { Log.e("EventDetailActivity", "Error when submitting feedback: " + error.getMessage()); dialog.dismiss(); Snackbar.make(findViewById(android.R.id.content), R.string.event_feedback_failed, Snackbar.LENGTH_SHORT).show(); } }); } }); } else { mMetricsManager.logEvent(R.string.analytics_event_feedback_already_submitted, null); Snackbar.make(findViewById(android.R.id.content), R.string.event_feedback_already_submitted, Snackbar.LENGTH_SHORT).show(); } } }; if (shouldShowFeedbackCard()) { findViewById(R.id.rateEventCardOk).setOnClickListener(feedbackOnClickListener); findViewById(R.id.rateEventCardNoThanks).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mMetricsManager.logEvent(R.string.analytics_event_feedback_no_thanks, null); UserStateStore.setFeedbackIgnored(EventDetailActivity.this, event.getId(), true); rateEventCard.setVisibility(View.GONE); } }); } else { findViewById(R.id.rateEventCard).setVisibility(View.GONE); } if (!mConfigManager.getValue(ConfigParam.EVENT_FEEDBACK)) { findViewById(R.id.rateEventCard).setVisibility(View.GONE); } }