List of usage examples for android.app AlertDialog setButton
public void setButton(int whichButton, CharSequence text, OnClickListener listener)
From source file:com.aikidonord.fragments.FragmentLieu.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_lieu, null /*container, false*/); View rlLoading = view.findViewById(R.id.loadingPanel); //View listView = view.getListView(); if (VerifConnexion.isOnline(this.getActivity())) { rlLoading.setVisibility(View.VISIBLE); // on va fair l'impasse l dessus vu que je ne suis pas bien sr // de la manire dont il faut oprer tant que la vue n'a pas t renvoye. //listView.setVisibility(View.GONE); this.lancementAsync(); } else {//from w ww. ja va2 s . c o m AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); alertDialog.setTitle(getResources().getString(R.string.app_name)); alertDialog.setMessage(getResources().getString(R.string.no_network)); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setCancelable(false); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity FragmentLieu.this.getActivity().finish(); } }); alertDialog.show(); } return view; }
From source file:com.aikidonord.fragments.FragmentType.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_type, null /*container, false*/); View rlLoading = view.findViewById(R.id.loadingPanel); //View listView = view.getListView(); if (VerifConnexion.isOnline(this.getActivity())) { rlLoading.setVisibility(View.VISIBLE); // on va fair l'impasse l dessus vu que je ne suis pas bien sr // de la manire dont il faut oprer tant que la vue n'a pas t renvoye. //listView.setVisibility(View.GONE); this.lancementAsync(); } else {//from ww w . j a v a 2s . c om AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); alertDialog.setTitle(getResources().getString(R.string.app_name)); alertDialog.setMessage(getResources().getString(R.string.no_network)); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setCancelable(false); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity FragmentType.this.getActivity().finish(); } }); alertDialog.show(); } return view; }
From source file:org.epstudios.epcoding.ProcedureDetailFragment.java
public void saveCoding() { // don't bother if no secondary codes to save if (secondaryCheckBoxMap.isEmpty()) { Toast toast = Toast.makeText(context, getString(R.string.no_secondary_codes_error_message), Toast.LENGTH_SHORT);//from w w w .j a va 2s.co m toast.show(); return; } AlertDialog dialog = new AlertDialog.Builder(context).create(); String message = "Save these selections as a default?"; dialog.setMessage(message); dialog.setTitle("Save Defaults"); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { save(); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); }
From source file:com.technologx.firebirddesigns.MainInterface.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bottom_interface); View main = findViewById(R.id.main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (main != null) { main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); }//from ww w . j a va 2 s . co m } AppCompatActivity activity = this; activity.setSupportActionBar(toolbar); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); activity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_toolbar); activity.getSupportActionBar().setTitle("Fire Bird Designs"); activity.getSupportActionBar().setSubtitle("News, Content and More"); UpdateChecker checker = new UpdateChecker(this); UpdateChecker.setStore(Store.GOOGLE_PLAY); UpdateChecker.setNoticeIcon(R.mipmap.ic_launcher); UpdateChecker.start(); result = new DrawerBuilder(this).withToolbar(toolbar).withDisplayBelowStatusBar(false) .withTranslucentStatusBar(false).withActionBarDrawerToggleAnimated(true) .withDrawerLayout(R.layout.material_drawer_fits_not).withHeader(R.layout.settings_header) .addDrawerItems(new SectionDrawerItem().withName("Application"), new PrimaryDrawerItem().withName("Notifications").withIdentifier(1), new PrimaryDrawerItem().withName("Homepage").withIdentifier(2), new ExpandableDrawerItem().withName("More").withSubItems( new PrimaryDrawerItem().withName("Settings").withIdentifier(3), new PrimaryDrawerItem().withName("License").withIdentifier(4), new PrimaryDrawerItem().withName("Contact").withIdentifier(5))) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { long id = drawerItem.getIdentifier(); if (id == 1) { Intent intent = new Intent(MainInterface.this, NewsfeedActivity.class); startActivity(intent); } else if (id == 2) { Intent intent = new Intent(MainInterface.this, WebViewActivity.class); startActivity(intent); } else if (id == 3) { Intent intent = new Intent(MainInterface.this, SettingsActivity.class); startActivity(intent); } else if (id == 4) { new LicensesDialog.Builder(MainInterface.this).setNotices(R.raw.licenses).build() .show(); } else if (id == 5) { AlertDialog alertDialog = new AlertDialog.Builder(MainInterface.this).create(); alertDialog.setTitle(getResources().getString(R.string.feedback_title)); alertDialog.setMessage(getResources().getString(R.string.feedback_summary)); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.email), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { sendEmail(); } }); alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getResources().getString(R.string.hangout), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startHangout(); } }); alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } return false; } }).withSavedInstance(savedInstanceState).build(); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); viewPager.setCurrentItem(1); viewPager.setPageTransformer(false, new ViewPager.PageTransformer() { @Override public void transformPage(View page, float position) { final float normalizedposition = Math.abs(Math.abs(position) - 1); page.setAlpha(normalizedposition); } }); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); if (mTabLayout != null) { mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); if (tab != null) tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } }
From source file:com.csipsimple.ui.calllog.CallLogListFragment.java
private void deleteAllCalls() { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle(R.string.callLog_delDialog_title); alertDialog.setMessage(getString(R.string.callLog_delDialog_message)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.callLog_delDialog_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null, null); }// ww w. j av a 2 s.c o m }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.callLog_delDialog_no), (DialogInterface.OnClickListener) null); try { alertDialog.show(); } catch (Exception e) { Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog"); } }
From source file:eu.betaas.betaasandroidapp.NavigationDrawerFragment.java
@Override public void onGatewayInstallFailure(Gateway gateway, String cause) { AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); alertDialog.setTitle("Alert"); alertDialog.setMessage("[" + gateway.getName() + "] : " + cause); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();/*from w ww.ja va 2s . com*/ } }); alertDialog.show(); }
From source file:eu.betaas.betaasandroidapp.NavigationDrawerFragment.java
@Override public void onGatewayUpdateFailure(Gateway gateway, String cause) { AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); alertDialog.setTitle("Alert"); alertDialog.setMessage("[" + gateway.getName() + "] : " + cause); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();//from w w w. jav a 2 s. c o m } }); alertDialog.show(); }
From source file:eu.betaas.betaasandroidapp.NavigationDrawerFragment.java
@Override public void onGatewayRemoveFailure(Gateway gateway, String cause) { AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create(); alertDialog.setTitle("Alert"); alertDialog.setMessage("[" + gateway.getName() + "] : " + cause); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();/*from ww w . j a va2s. co m*/ } }); alertDialog.show(); }
From source file:com.github.sgelb.booket.SearchResultActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search_results); getActionBar().setDisplayHomeAsUpEnabled(true); noResults = (TextView) findViewById(R.id.noResultsTextView); defaultThumbnail = BitmapFactory.decodeResource(getResources(), R.drawable.ic_default_cover); bookList = new ArrayList<>(); resultList = (ListView) findViewById(R.id.searchResultsList); downloadProgressBar = (ProgressBar) findViewById(R.id.downloadProgressBar); datasource = new BooksDataSource(this); BookInfos bookInfos = new BookInfos(); bookInfos.execute(createUrl());/*from ww w .ja va 2s . c om*/ adapter = new BookResultAdapter(bookList, this); resultList.setAdapter(adapter); // Save book in database resultList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog alert = new AlertDialog.Builder(SearchResultActivity.this).create(); alert.setTitle( Html.fromHtml(getString(R.string.dialog_save_book, bookList.get(position).getTitle()))); alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { saveBook(position); } }); alert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { } }); alert.show(); return true; } }); // Expand list row resultList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { adapter.toggleExpand(view, position); } }); }
From source file:com.prof.rssparser.example.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { android.support.v7.app.AlertDialog alertDialog = new android.support.v7.app.AlertDialog.Builder( MainActivity.this).create(); alertDialog.setTitle(R.string.app_name); alertDialog.setMessage(Html.fromHtml(MainActivity.this.getString(R.string.info_text) + " <a href='http://github.com/prof18/RSS-Parser'>GitHub.</a>" + MainActivity.this.getString(R.string.author))); alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }// www . j a v a 2s .com }); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } return super.onOptionsItemSelected(item); }