当前位置: 首页>>代码示例>>Java>>正文


Java Builder.setPositiveButton方法代码示例

本文整理汇总了Java中android.support.v7.app.AlertDialog.Builder.setPositiveButton方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.setPositiveButton方法的具体用法?Java Builder.setPositiveButton怎么用?Java Builder.setPositiveButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.app.AlertDialog.Builder的用法示例。


在下文中一共展示了Builder.setPositiveButton方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showInfoDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
private void showInfoDialog(int id, String courseName, CourseInfo course) {
    selectedCourseNo = course.getCourseNo();
    Builder course_dialog_builder = new AlertDialog.Builder(getActivity());
    course_dialog_builder.setTitle(courseName);
    String message = String.format(Locale.TAIWAN, "%s%s\n%s%s\n%s%s\n%s%s",
            getString(R.string.course_courseid), course.getCourseNo(),
            getString(R.string.course_classtime), TIME_ARRAY[id - 1],
            getString(R.string.course_classplace), course.getCourseRoom(),
            getString(R.string.course_classteacher), course.getCourseTeacher());
    course_dialog_builder.setMessage(message);
    course_dialog_builder.setPositiveButton(R.string.course_classdetail, courseDetailDialogLis);
    course_dialog_builder.show();
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:14,代码来源:CourseFragment.java

示例2: showDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
public static void showDialog(String title, String msg, Context context) {
    Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(msg);
    builder.setPositiveButton(R.string.back, null);
    builder.show();
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:8,代码来源:Utility.java

示例3: scanWifi

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
public void scanWifi() {
    if (!checkPermission()) {
        if (activityContext instanceof MainActivity) {
            ((MainActivity) activityContext).requestPermission(Manifest.permission.ACCESS_COARSE_LOCATION, this);
        }
        return;
    }
    if (!WifiUtility.isWifiOpen(MainApplication.getInstance())) {
        Builder checkDialog = new AlertDialog.Builder(activityContext);
        checkDialog.setTitle(R.string.hint);
        checkDialog.setMessage(R.string.wifi_needenable);
        checkDialog.setPositiveButton(R.string.wifi_enable,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (!isScan) {
                            isScan = true;
                            WifiUtility.openWifi(MainApplication
                                    .getInstance());
                            WifiUtility.startScan(activityContext,
                                    wifiReceiver);
                        }
                    }
                });
        checkDialog.setNegativeButton(R.string.back, null);
        checkDialog.show();
    } else {
        if (!isScan) {
            isScan = true;
            WifiUtility.startScan(activityContext, wifiReceiver);
        }
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:34,代码来源:WifiFragment.java

示例4: onClick

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    selectedEvent = (EventInfo) v.getTag(R.id.data_tag);
    Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.activity_detail);
    String message = null;
    if (selectedEvent.getStartDate().compareTo(selectedEvent.getEndDate()) == 0) {
        message = String.format(
                Locale.TAIWAN,
                "%s\n\n" + getContext().getString(R.string.activity_date) + "%s",
                selectedEvent.getEvent(),
                Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getStartDate(), getContext()));
    } else {
        message = String.format(
                Locale.TAIWAN,
                "%s\n\n" + getContext().getString(R.string.activity_startdate) + "%s\n" + getContext().getString(R.string.activity_enddate) + "%s",
                selectedEvent.getEvent(),
                Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getStartDate(), getContext()),
                Utility.getDateString("yyyy/MM/dd (E)",
                        selectedEvent.getEndDate(), getContext()));
    }
    builder.setMessage(message);
    builder.setNegativeButton(R.string.add_to_calendar, this);
    builder.setPositiveButton(R.string.share_using, this);
    builder.show();
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:29,代码来源:CalendarListAdapter.java

示例5: onCreateDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
   public AppCompatDialog onCreateDialog(Bundle savedInstanceState)
   {
	
   	Builder builder = new AlertDialog.Builder(getActivity());
   	builder.setTitle("test fragment mode");
   	oh = getArguments().getString(KEY_OH);
   	
	builder.setPositiveButton(android.R.string.ok, null);

   	return builder.create();
   }
 
开发者ID:simonpoole,项目名称:OpeningHoursFragment,代码行数:15,代码来源:TestFragment.java

示例6: onCreateDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
   @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Bundle arguments = getArguments();
       if (arguments == null) {
           throw new IllegalStateException("Arguments are missing");
       }
       Context context = getActivity();
       Builder builder = new Builder(context);

       int titleResId = arguments.getInt(TITLE_ARGUMENT);
       if (titleResId > 0) {
           builder.setTitle(titleResId);
       } else {
           String title = arguments.getString(TITLE_STRING_ARGUMENT);
           if (title != null) {
               builder.setTitle(title);
           }
       }

       int viewLayoutId = arguments.getInt(VIEW_LAYOUT_ARGUMENT);
       if (viewLayoutId > 0) {
           dialogView = LayoutInflater.from(context).inflate(viewLayoutId, null);
           if (savedInstanceState != null) {
               SparseArray<Parcelable> states = savedInstanceState.getSparseParcelableArray(SAVED_DIALOG_VIEW_STATE);
               dialogView.restoreHierarchyState(states);
           }
           builder.setView(dialogView);
       } else {
           int msgResId = arguments.getInt(MESSAGE_ARGUMENT);
           if (msgResId > 0) {
               builder.setMessage(msgResId);
           } else {
               String message = arguments.getString(MESSAGE_STRING_ARGUMENT);
               if (message != null) {
                   builder.setMessage(message);
               }
           }
       }

	builder.setPositiveButton(arguments.getInt(POSITIVE_BUTTON_ARGUMENT, android.R.string.ok), this);
       if (arguments.getBoolean(NEGATIVE_BUTTON_VISIBLE_ARGUMENT, true)) {
	    builder.setNegativeButton(arguments.getInt(NEGATIVE_BUTTON_ARGUMENT, android.R.string.cancel), this);
       }

       AlertDialog alertDialog = builder.create();
       alertDialog.setCanceledOnTouchOutside(arguments.getBoolean(CANCELED_ON_TOUCH_OUTSIDE_ARGUMENT, true));

       if (dialogView != null) {
           //Tem que definir isto para que o teclado abra na View focada.
           alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
       }

       return alertDialog;
}
 
开发者ID:ZalemSoftware,项目名称:Ymir,代码行数:56,代码来源:ConfirmationDialogFragment.java

示例7: onCreateDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
   @NonNull
   @SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
	//Obtém os argumentos (opcionais)
	int titleId = 0;
	ArrayList<MessageGroup> messageGroups = null;

	Bundle arguments = getArguments();
	if (arguments != null) {
		titleId = arguments.getInt(DIALOG_TITLE_ARGUMENT);
		messageGroups = arguments.getParcelableArrayList(MESSAGE_GROUPS_ARGUMENT);
	}

	//Cria a View customizada do dialog.
	Context context = getActivity();
	LayoutInflater layoutInflater = LayoutInflater.from(context);
	View view = layoutInflater.inflate(R.layout.entity_editing_message_list_dialog, null);
	TextView messageView = (TextView) view.findViewById(R.id.entity_editing_message_list_dialog_text);

	if (messageGroups == null || messageGroups.isEmpty()) {
		messageView.setText(R.string.entity_editing_message_list_dialog_message_empty);
	} else {
		messageView.setText(R.string.entity_editing_message_list_dialog_message);

		//Só define o adapter se houver mensagens.
		ListView listView = (ListView) view.findViewById(R.id.entity_editing_message_list_dialog_list);
		listView.setAdapter(new MessageAdapter(context, messageGroups));
	}

	Builder builder = new Builder(context);
	builder.setPositiveButton(android.R.string.ok, null);
	builder.setView(view);

	//Define o título do dialog, se houver.
	if (titleId != 0) {
		builder.setTitle(titleId);
	}

       AlertDialog dialog = builder.create();
       AndroidBugsUtils.applyWorkaroundForAlertDialogWithFlexibleListViewBug(dialog, view);
       return dialog;
}
 
开发者ID:ZalemSoftware,项目名称:Ymir,代码行数:44,代码来源:EntityEditingMessageListDialogFragment.java

示例8: showTransport

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
private void showTransport() {
    //TODO : Do this properly
    Builder b = new Builder(this);
    b.setTitle("Select default route");

    String[] types = new String[routeDataList.size()];

    for (RouteData s : routeDataList) {
        types[routeDataList.indexOf(s)] = s.getOrigin().toUpperCase() + "-" + s.getDestination().toUpperCase() + " " + s.getType();
        if (s.getFavorite().equals("yes")) {
            types[routeDataList.indexOf(s)] = types[routeDataList.indexOf(s)] + " (default)";
        }
    }
    b.setPositiveButton(cancel, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    b.setItems(types, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            prefs.setFavoriteOrigin(routeDataList.get(which).getOrigin());
            prefs.setFavoriteDestination(routeDataList.get(which).getDestination());
            prefs.setFavoriteType(routeDataList.get(which).getType());
            CommonTasks.sendFavoriteRoute(getApplicationContext(), routeDataList.get(which).getRouteID());
            prefs.defaultRouteSet();
            for (int i = 0; i < routeDataList.size(); i++) {
                if (i == which) {
                    routeDataList.get(i).setFavorite("yes");
                } else {
                    routeDataList.get(i).setFavorite("no");
                }
            }
            dialog.dismiss();
            setUpItems();
            Snackbar snackbar = Snackbar.make(recyclerView, "Default route changed!", BaseTransientBottomBar.LENGTH_SHORT);
            snackbar.getView().setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.green));
            snackbar.show();
        }

    });
    b.show();
}
 
开发者ID:NCBSinfo,项目名称:NCBSinfo,代码行数:45,代码来源:Settings.java

示例9: onCreateDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
    int title = getArguments().getInt(TITLE);
    final int min = getArguments().getInt(MIN);
    final int max = getArguments().getInt(MAX);
    int startCurrent = getArguments().getInt(START_CURRENT);
    int endCurrent = getArguments().getInt(END_CURRENT);
    final SetRangeListener listener = (SetRangeListener) getParentFragment();

    // Preferences prefs= new Preferences(getActivity());
    Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(title);

    final LayoutInflater inflater = getActivity().getLayoutInflater(); // ThemeUtils.getLayoutInflater(getActivity());

    // DoNothingListener doNothingListener = new DoNothingListener();
    View layout = inflater.inflate(R.layout.rangepicker, null);
    builder.setView(layout);

    String[] startValues = new String[max - min + 1];
    for (int i = min; i <= max; i++) {
        startValues[i - min] = Integer.toString(i);
    }
    final NumberPickerView npvStart = (NumberPickerView) layout.findViewById(R.id.start);
    npvStart.setDisplayedValues(startValues);
    npvStart.setMinValue(min);
    npvStart.setMaxValue(max);
    npvStart.setValue(startCurrent);

    String[] endValues = new String[max - min + 2];
    endValues[0] = "-";
    for (int i = min; i <= max; i++) {
        endValues[i - min + 1] = Integer.toString(i);
    }
    final NumberPickerView npvEnd = (NumberPickerView) layout.findViewById(R.id.end);
    npvEnd.setDisplayedValues(endValues);
    npvEnd.setMinValue(min - 1);
    npvEnd.setMaxValue(max);
    if (endCurrent == NOTHING_SELECTED) {
        endCurrent = min - 1;
    }
    npvEnd.setValue(endCurrent);

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            int endValue = npvEnd.getValue();
            if (endValue == min - 1) {
                endValue = NOTHING_SELECTED;
            }
            listener.setRange(npvStart.getValue(), endValue);
        }
    });
    builder.setNeutralButton(android.R.string.cancel, null);

    return builder.create();
}
 
开发者ID:simonpoole,项目名称:OpeningHoursFragment,代码行数:60,代码来源:RangePicker.java

示例10: onCreateDialog

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
    int title = getArguments().getInt(TITLE);

    int startHour = getArguments().getInt(START_HOUR);
    int startMinute = getArguments().getInt(START_MINUTE);
    int endHour = getArguments().getInt(END_HOUR);
    int endMinute = getArguments().getInt(END_MINUTE);

    boolean startOnly = getArguments().getBoolean(START_ONLY);

    final SetTimeRangeListener listener = (SetTimeRangeListener) getParentFragment();

    // Preferences prefs= new Preferences(getActivity());
    Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(title);

    final LayoutInflater inflater = getActivity().getLayoutInflater(); // ThemeUtils.getLayoutInflater(getActivity());

    // DoNothingListener doNothingListener = new DoNothingListener();
    View layout = inflater.inflate(R.layout.timerangepicker, null);
    builder.setView(layout);

    String[] hourValues = new String[48];
    for (int i = 0; i < 48; i++) {
        hourValues[i] = String.format("%02d", i);
    }
    final NumberPickerView npvStartHour = (NumberPickerView) layout.findViewById(R.id.startHour);
    npvStartHour.setDisplayedValues(hourValues);
    npvStartHour.setMinValue(0);
    npvStartHour.setMaxValue(23);
    npvStartHour.setValue(startHour);

    String[] minValues = new String[60];
    for (int i = 0; i < 60; i++) {
        minValues[i] = String.format("%02d", i);
    }

    final NumberPickerView npvStartMinute = (NumberPickerView) layout.findViewById(R.id.startMinute);

    npvStartMinute.setDisplayedValues(minValues);
    npvStartMinute.setMinValue(0);
    npvStartMinute.setMaxValue(59);
    npvStartMinute.setValue(startMinute);

    final NumberPickerView npvEndHour = (NumberPickerView) layout.findViewById(R.id.endHour);
    final NumberPickerView npvEndMinute = (NumberPickerView) layout.findViewById(R.id.endMinute);
    if (startOnly) {
        npvEndHour.setVisibility(View.GONE);
        npvEndMinute.setVisibility(View.GONE);
    } else {
        npvEndHour.setVisibility(View.VISIBLE);
        npvEndMinute.setVisibility(View.VISIBLE);
        npvEndHour.setDisplayedValues(hourValues);
        npvEndHour.setMinValue(0);
        npvEndHour.setMaxValue(47);
        npvEndHour.setValue(endHour);

        npvEndMinute.setDisplayedValues(minValues);
        npvEndMinute.setMinValue(0);
        npvEndMinute.setMaxValue(59);
        npvEndMinute.setValue(endMinute);
    }

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            int startHourValue = npvStartHour.getValue();
            int startMinuteValue = npvStartMinute.getValue();
            int endHourValue = npvEndHour.getValue();
            int endMinuteValue = npvEndMinute.getValue();

            listener.setTimeRange(startHourValue, startMinuteValue, endHourValue, endMinuteValue);
        }
    });
    builder.setNeutralButton(android.R.string.cancel, null);

    return builder.create();
}
 
开发者ID:simonpoole,项目名称:OpeningHoursFragment,代码行数:82,代码来源:TimeRangePicker.java

示例11: onPrepareDialogBuilder

import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
  protected void onPrepareDialogBuilder(Builder builder)
    {
    super.onPrepareDialogBuilder(builder);
    if(mEntries==null||mEntryValues==null)
      {
      throw new IllegalStateException(
              "ListPreference requires an entries array and an entryValues array.");
      }
    mClickedDialogEntryIndex=getValueIndex();
    //    final ListView listView=new ListView(getContext());
//    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
//    listView.setOnItemClickListener(new OnItemClickListener()
//    {
//    @Override
//    public void onItemClick(final AdapterView<?> parent,final View view,final int position,final long id)
//      {
//      listView.setItemChecked(position,true);
//      if(position>=0&&getEntryValues()!=null)
//        {
//        String value=getEntryValues()[position].toString();
//        if(callChangeListener(value)&&isPersistent())
//          setValue(value);
//        }
//      mDialog.dismiss();
//      }
//    });
//    listView.setAdapter(new ArrayAdapter<>(getContext(),R.layout.mpl__simple_list_item_single_choice,entries));
    //            builder.setView(listView);

    builder.setSingleChoiceItems(new ArrayAdapter<>(getContext(),R.layout.mpl__simple_list_item_single_choice,mEntries),mClickedDialogEntryIndex,
            new DialogInterface.OnClickListener()
            {
            public void onClick(DialogInterface dialog,int which)
              {
              mClickedDialogEntryIndex=which;

                        /*
                         * Clicking on an item simulates the positive button
                         * click, and dismisses the dialog.
                         */
              ListPreference.this.onClick(dialog,DialogInterface.BUTTON_POSITIVE);
              dialog.dismiss();
              }
            });

        /*
         * The typical interaction for list-based dialogs is to have
         * click-on-an-item dismiss the dialog instead of the user having to
         * press 'Ok'.
         */
    builder.setPositiveButton(null,null);
    }
 
开发者ID:AndroidDeveloperLB,项目名称:MaterialPreferenceLibrary,代码行数:54,代码来源:ListPreference.java


注:本文中的android.support.v7.app.AlertDialog.Builder.setPositiveButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。