Java Code Examples for android.support.v7.app.AlertDialog.setTitle()

The following are Jave code examples for showing how to use setTitle() of the android.support.v7.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Overkill   File: MainActivity.java   Source Code and License Vote up 6 votes
private void checkInternetConnection() {
    ConnectivityManager  cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if ( netInfo == null || !netInfo.isConnectedOrConnecting() ) {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("Warning");
        alertDialog.setMessage("This app has limited functions without the internet connection.");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }
}
 
Example 2
Project: Overkill   File: MainActivity.java   Source Code and License Vote up 6 votes
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode == MYPERMISSION) {
        if (grantResults.length < 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
            AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
            alertDialog.setTitle("Please!!");
            alertDialog.setMessage("ALLOW map permission.");
            alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alertDialog.show();
        }
    }
}
 
Example 3
Project: Goalie_Android   File: GoalsDetailedDialog.java   Source Code and License Vote up 6 votes
private void delete() {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle(getString(R.string.are_you_sure));
    alertDialog.setMessage(getString(R.string.no_refund));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            GoalHelper.getInstance().deleteGoal(mGuid);
            Intent returnIntent = new Intent();
            String goalCompleteResultString = String.valueOf(Goal.GoalCompleteResult.Cancelled.ordinal());
            returnIntent.putExtra("goalCompleteResultInt", goalCompleteResultString);
            getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, returnIntent);
            dismiss();
        }
    });
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), (DialogInterface.OnClickListener) null);
    alertDialog.show();
}
 
Example 4
Project: Minitask   File: AddTodoItem.java   Source Code and License Vote up 6 votes
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
    // if the date is in the past tell user to choose again
    if (dateTimeUtils.checkInvalidDate(year, monthOfYear, dayOfMonth)){
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Date not valid!");
        alertDialog.setIcon(R.drawable.ic_warning_black_24dp);
        alertDialog.setMessage("You are selecting a time a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set date value to the value user selected and change the text
    date = dateTimeUtils.dateToString(year, monthOfYear, dayOfMonth);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 5
Project: Minitask   File: AddTodoItem.java   Source Code and License Vote up 6 votes
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
    // if date is not chosen first but time is chosen -> make today the default date.
    // also check for valid time, must be today but not the past hour or minutes.
    if (date.equals(dateTimeUtils.fillDateIfEmpty("")) && dateTimeUtils.checkInvalidTime(hourOfDay, minute)) {
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Time not valid!");
        alertDialog.setMessage("You are selecting a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set time value and update text
    time = dateTimeUtils.timeToString(hourOfDay, minute);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 6
Project: Roomie   File: BackpackActivity.java   Source Code and License Vote up 5 votes
private void showDialog(String message)
{
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Warning!");
    alertDialog.setMessage(message);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 7
Project: happy-news   File: PostFragment.java   Source Code and License Vote up 5 votes
/**
 * Refresh the content.
 *
 * <p>Shows an error message when the app is not connected to the internet.
 */
protected void refresh() {
    ConnectivityManager connectivityManager = (ConnectivityManager) getActivity().getSystemService(Context
        .CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();

    boolean isConnected = activeNetwork != null && activeNetwork.isConnected();

    if (!isConnected) {
        AlertDialog alert = new AlertDialog.Builder(getActivity()).create();

        alert.setTitle(getString(R.string.network_error_title));
        alert.setMessage(getString(R.string.no_internet_message));
        alert.setButton(RESULT_OK, getString(R.string.retry_button), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //Display an error if still not connected
                refresh();
            }
        });

        alert.show();
    } else {
        swipeRefresh.setRefreshing(true);
        loading = true;

        doRefresh(postManager, refreshCallback);
    }
}
 
Example 8
Project: updateUtils   File: UpdateAgent.java   Source Code and License Vote up 5 votes
@Override
public void onPrompt(UpdateAgent agent) {
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new OnPromptClick(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}
 
Example 9
Project: Goalie_Android   File: NewGoalFragment.java   Source Code and License Vote up 5 votes
@Override
public void onSetGoal(boolean isSuccessful, String errMsg) {
    if (isSuccessful) {
        Toast.makeText(getActivity(), getString(R.string.ok_goal), Toast.LENGTH_SHORT).show();
        getActivity().setResult(Activity.RESULT_OK);
        getActivity().finish();
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
        alertDialog.setTitle(getString(R.string.error_goal));
        alertDialog.setMessage(errMsg);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), (DialogInterface.OnClickListener) null);
        alertDialog.show();
    }
}
 
Example 10
Project: MobileAppForPatient   File: RegisterUser.java   Source Code and License Vote up 5 votes
@Override
protected void initUI() {
    mScrollView = (ScrollView) findViewById(R.id.scroll_register_user);

    initUserName();
    initPassword();
    initGivenName();
    initEmail();
    initPhone();
    initFamilyName();
    initGenderSpinner();
    initBirthDate();
    initCity();
    initButtonSignUp();

    AlertDialog alertDialog = new AlertDialog.Builder(RegisterUser.this).create();
    alertDialog.setTitle("Message");
    final Intent changePssActivity = new Intent(this, LoginActivity.class);
    alertDialog.setMessage("Call your API for Register your User");
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(changePssActivity);
                    finish();
                }
            });
    alertDialog.show();
}
 
Example 11
Project: S3-16-simone   File: FullscreenBaseGameActivity.java   Source Code and License Vote up 5 votes
private void showConnectionErrorDialog(){
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Connection error");
    alertDialog.setMessage("Simone was not able to reach Google Games. Enable connection to improve your experience with Simone.");
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 12
Project: BackendDrivenMenu   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.about) {
        final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.about_title));
        ImageView iv = new ImageView(this);
        int p = G.dpToPx(this, 10);
        iv.setPadding(p, G.dpToPx(this, 20), p, p);
        iv.setImageDrawable(logo);
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                visitWeb();
                alertDialog.hide();
            }
        });
        alertDialog.setView(iv);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.visit_web), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                visitWeb();
            }
        });
        alertDialog.setCancelable(true);
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 13
Project: kqsse17   File: AlertDialogHelper.java   Source Code and License Vote up 5 votes
public static AlertDialog buildAlertDialog(Context ctx, String title, String button) {
    AlertDialog ad = new AlertDialog.Builder(ctx).create();
    ad.setTitle(title);
    ad.setButton(AlertDialog.BUTTON_NEUTRAL, button,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }
    );
    return ad;
}
 
Example 14
Project: GitHub   File: UpdateAgent.java   Source Code and License Vote up 4 votes
@Override
public void prompt(IUpdateAgent agent) {
    if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
        return;
    }
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}
 
Example 15
Project: update-master   File: UpdateAgent.java   Source Code and License Vote up 4 votes
@Override
public void prompt(IUpdateAgent agent) {
    if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
        return;
    }
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}
 
Example 16
Project: TapIn   File: employeeTimetable.java   Source Code and License Vote up 4 votes
public void getCurrentEmployees()
{
    final ArrayList<String> info = new ArrayList<String>();

    BackgroundTask backgroundTask = new BackgroundTask(new BackgroundTask.AsyncResponse()
    {
        @Override
        public void processFinish(String output)
        {
            if (output.equals("null"))
            {
                spinner.setVisibility(View.INVISIBLE);

                AlertDialog alertDialog = new AlertDialog.Builder(employeeTimetable.this).create();
                alertDialog.setTitle("Sorry");
                alertDialog.setMessage("Some has gone wrong. Please Try Again Later");
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Okay",
                        new DialogInterface.OnClickListener()
                        {
                            public void onClick(DialogInterface dialog, int which)
                            {
                                Intent intent2 = new Intent(getApplicationContext(), EmployerMain.class);
                                intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(intent2);
                                finish();
                            }
                        });
                alertDialog.show();
            }
            else
            {
                String[] tokens = output.split("-");

                for (String t : tokens)
                {
                    info.add(t);
                }

                for (int i = 0; i < info.size(); i++)
                {
                    String employee = info.get(i);

                    String[] splitInfo = employee.split(",");

                    Employee n = new Employee(i, splitInfo[0], splitInfo[1], splitInfo[2], splitInfo[3], splitInfo[4], splitInfo[5]);
                    currentEmployees.add(n);
                }

                spinner.setVisibility(View.INVISIBLE);
                scroll = new EmployeeScroll(getApplicationContext(), currentEmployees, 1);
                listView.setAdapter(scroll);

                scroll.day = day;
                scroll.month = month;
            }
        }
    });
    if( BackgroundTask.isNetworkAvailable(employeeTimetable.this))
    {
        backgroundTask.execute("eWorkingCheck", cid, day, month);
    }
    else
    {
        finish();
        Toast.makeText(employeeTimetable.this,"No internet connection", Toast.LENGTH_LONG ).show();
    }

}
 
Example 17
Project: CuYemek   File: MainActivity.java   Source Code and License Vote up 4 votes
@Override
public void onItem(int index) {
    if (!networkControl()){
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("İnternet Yok !");
        alertDialog.setMessage("Lütfen internet bağlantısını kontrol ediniz.");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Tamam",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }else{

        String[] cafeterias = getResources().getStringArray(R.array.cafeterias);

        TextView tvCafeterias = toolbar.findViewById(R.id.tvCafeterias);
        tvCafeterias.setText(cafeterias[index]);

        Eat eat = new Eat();
        if (eatList.getEats().size() != 0){
            eat = eatList.getEats().get(index);
            Bundle bundle = new Bundle();
            bundle.putSerializable("eat", eat);
            transaction = fragmentManager.beginTransaction();
            CafeteriaDetailFragment cafeteriaDetailFragment = new CafeteriaDetailFragment();
            cafeteriaDetailFragment.setArguments(bundle);
            transaction.replace(R.id.container , cafeteriaDetailFragment);
            transaction.addToBackStack(null);
            transaction.commit();
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    fragmentManager.popBackStack();
                    reNameTitle();
                    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                }
            });
        }
    }

}
 
Example 18
Project: Lamp   File: TimingActivity.java   Source Code and License Vote up 4 votes
private void sendTime() {
    if (switchOpen) {

        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle(getResources().getString(R.string.remind));
        dialog.setMessage(getResources().getString(R.string.wait));
        dialog.show();

        Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int min = c.get(Calendar.MINUTE);

        String hourStr = hour + "";
        String minStr = min + "";

        if (hour < 10) {
            hourStr = "0" + hour + "";
        }

        if (min < 10) {
            minStr = "0" + min + "";
        }

        ControlLight.sendTime(CommandUtils.TIMING_CURRENT, hourStr, minStr);
        startAPM.postDelayed(new Runnable() {
            @Override
            public void run() {
                ControlLight.sendTime(CommandUtils.TIMING_ON_1, time[0], time[1]);

                startAPM.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ControlLight.sendTime(CommandUtils.TIMING_ON_2, time[2], time[3]);
                        dialog.cancel();
                        finishThis();
                    }
                }, 1000);

            }
        }, 1000);


    } else {
        ControlLight.sendOrder(CommandUtils.TIMING_OFF);

        finishThis();
    }

}
 
Example 19
Project: MobileAppForPatient   File: SettingsActivity.java   Source Code and License Vote up 4 votes
@Override
protected void initUI() {

    AlertDialog alertDialog = new AlertDialog.Builder(SettingsActivity.this).create();
    alertDialog.setTitle("Message");
    final Intent changePssActivity = new Intent(this, DashboardActivity.class);
    alertDialog.setMessage("Call your API for setting device send timeout");
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(changePssActivity);
                    finish();
                }
            });
    alertDialog.show();

    mNewSettings = new CognitoUserSettings();
    settingsChanged = false;
   // mSmsSwitch = (Switch) findViewById(R.id.switchSettingsPhone);
    mTxtDataIntervalTitle = (TextView) findViewById(R.id.textViewDataIntervalTitle);
    mTxtDataIntervalValue = (TextView) findViewById(R.id.textViewDataIntervalValue);
    //mSettings = CognitoHelper.getUserDetails().getSettings().getSettings();

    if (mSmsSwitch != null) {
        mSmsSwitch.setClickable(true);
        mSmsSwitch.setChecked(false);
        mSmsSwitch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toggleSwitch();
                if (mSmsSwitch.isChecked()) {
                    updateSetting(Constants.phoneNumber, Constants.SMS1);
                } else {
                    updateSetting(Constants.phoneNumber, null);
                }
            }
        });
    }
    if (mSettings != null) {
        if (mSettings.containsKey(Constants.phoneNumber) && mSmsSwitch != null) {
            mSmsSwitch.setClickable(true);
            if (mSettings.get(Constants.phoneNumber).contains(Constants.SMS) || mSettings.get(Constants.phoneNumber).contains(Constants.SMS1)) {
                mSmsSwitch.setChecked(true);
                mSmsSwitch.setTextColor(Color.parseColor("#37A51C"));
            } else {
                mSmsSwitch.setChecked(false);
                mSmsSwitch.setTextColor(Color.parseColor("#E94700"));
            }
        }
    }
}