Java Code Examples for android.widget.RadioGroup#check()

The following examples show how to use android.widget.RadioGroup#check() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CareBehaviorScheduleFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override public View onCreateView(
      @NonNull LayoutInflater inflater,
      ViewGroup container,
      Bundle savedInstanceState
) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    noSchedulesCopyLayout = (LinearLayout) view.findViewById(R.id.no_schedules_copy);
    addEventButton = (Version1Button) view.findViewById(R.id.add_event_button);
    dayOfWeekGroup = (RadioGroup) view.findViewById(R.id.day_of_week_radio_group);
    schedulesList = (ListView) view.findViewById(R.id.schedules);

    dayOfWeekGroup.check(R.id.radio_monday);

    TextView noScheduleCopyTitle = (TextView) view.findViewById(R.id.no_schedules_copy_title);
    TextView noSchedulesCopyDesc = (TextView) view.findViewById(R.id.no_schedules_copy_desc);
    noScheduleCopyTitle.setText(getString(R.string.care_no_schedule_header_title));
    noSchedulesCopyDesc.setText(getString(R.string.care_no_schedule_header_desc));

    return view;
}
 
Example 2
Source File: WrapLayoutActivity.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSupportActionBar(R.id.wl_toolbar);
    mVContent = findViewById(R.id.wl_wl_content);
    final RadioGroup gravity = findViewById(R.id.wl_rg_gravity);
    final SeekBar horizontal = findViewById(R.id.wl_sb_horizontal);
    final SeekBar vertical = findViewById(R.id.wl_sb_vertical);

    gravity.setOnCheckedChangeListener(this);
    gravity.check(R.id.wl_rb_top);
    horizontal.setOnSeekBarChangeListener(this);
    horizontal.setProgress(15);
    vertical.setOnSeekBarChangeListener(this);
    vertical.setProgress(15);
}
 
Example 3
Source File: NewSensorLocation.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_sensor_location);
    button = (Button)findViewById(R.id.saveSensorLocation);
    buttonCancel = (Button)findViewById(R.id.saveSensorLocationCancel);
    sensor_location_other = (EditText) findViewById(R.id.edit_sensor_location);
    sensor_location_other.setEnabled(false);
    DontAskAgain = (CheckBox)findViewById(R.id.sensorLocationDontAskAgain);
    radioGroup = (RadioGroup) findViewById(R.id.myRadioGroup);
    addListenerOnButton();

    locations = new LinkedList<Location>();

    locations.add(new Location("I don't wish to share", PRIVATE_ID));
    locations.add(new Location("Upper arm", 1));
    locations.add(new Location("Thigh", 2));
    locations.add(new Location("Belly (abdomen)", 3));
    locations.add(new Location("Lower back", 4));
    locations.add(new Location("Buttocks", 5));
    locations.add(new Location("Other", OTHER_ID));

    for(Location location : locations) {
        AddButton(location.location, location.location_id);
    }
    radioGroup.check(PRIVATE_ID);

}
 
Example 4
Source File: BaseThreadAndArticleAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 过滤条件的item
 */
public View getForumFilterItem(int position, View convertView) {
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.item_forum_filter_recomm, null);
    }
    RadioGroup group = ViewHolder.get(convertView, R.id.radio);
    //group.getLayoutParams().height=(int)context.getResources().getDimension(R.dimen.height_default);

    int[] ids = {R.id.radioButton1, R.id.radioButton2, R.id.radioButton3, R.id.radioButton4};
    group.check(ids[forumFilterSelectIndex]);
    for (int i = 0; i < ids.length; i++) {
        RadioButton radioButton = ViewHolder.get(convertView, ids[i]);
        final int index = i;
        radioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (forumFilterSelectIndex == index) {
                    return;
                }
                forumFilterSelectIndex = index;
                if (doSomeThing != null) {
                    doSomeThing.execute(forumFilterSelectIndex);
                }
            }
        });
    }
    return convertView;
}
 
Example 5
Source File: TypeContentIndexPageAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 过滤条件的item
 */
public View getForumFilterItem(int position, View convertView) {
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.item_forum_filter_recomm, null);
    }
    RadioGroup group = ViewHolder.get(convertView, R.id.radio);

    int index = getHomePageIndex(position);
    final Recommend recommend = homePage.get(index).getRecommend();
    ArrayList<ThreadConfig> threadConfigItems = recommend.getThreadConfigs();

    int[] ids = {R.id.radioButton1, R.id.radioButton2, R.id.radioButton3, R.id.radioButton4};
    group.check(ids[recommend.getForumFilterSelectIndex()]);

    for (int i = 0; i < ids.length; i++) {
        RadioButton radioButton = ViewHolder.get(convertView, ids[i]);
        if (threadConfigItems != null && i < threadConfigItems.size()) {
            ThreadConfig item = threadConfigItems.get(i);
            radioButton.setVisibility(View.VISIBLE);
            radioButton.setText(getFilterItemTitle(item));
        } else {
            radioButton.setVisibility(View.GONE);
        }
        final int ii = i;
        radioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                filterItemClick(recommend, ii);
            }
        });
    }
    return convertView;
}
 
Example 6
Source File: ContainerTransformConfigurationHelper.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/** Set up interpolation */
private void setUpBottomSheetInterpolation(View view) {
  RadioGroup interpolationGroup = view.findViewById(R.id.interpolation_radio_group);
  ViewGroup customContainer = view.findViewById(R.id.custom_curve_container);
  if (interpolationGroup != null && customContainer != null) {

    setTextInputClearOnTextChanged(view.findViewById(R.id.x1_text_input_layout));
    setTextInputClearOnTextChanged(view.findViewById(R.id.x2_text_input_layout));
    setTextInputClearOnTextChanged(view.findViewById(R.id.y1_text_input_layout));
    setTextInputClearOnTextChanged(view.findViewById(R.id.y2_text_input_layout));

    // Check the correct current radio button and fill in custom bezier fields if applicable.
    if (interpolator instanceof FastOutSlowInInterpolator) {
      interpolationGroup.check(R.id.radio_fast_out_slow_in);
    } else {
      interpolationGroup.check(R.id.radio_custom);
      CustomCubicBezier currentInterp = (CustomCubicBezier) interpolator;
      setTextFloat(view.findViewById(R.id.x1_edit_text), currentInterp.controlX1);
      setTextFloat(view.findViewById(R.id.y1_edit_text), currentInterp.controlY1);
      setTextFloat(view.findViewById(R.id.x2_edit_text), currentInterp.controlX2);
      setTextFloat(view.findViewById(R.id.y2_edit_text), currentInterp.controlY2);
    }

    // Enable/disable custom bezier fields depending on initial checked radio button.
    setViewGroupDescendantsEnabled(
        customContainer, interpolationGroup.getCheckedRadioButtonId() == R.id.radio_custom);

    // Watch for any changes to the selected radio button and update custom bezier enabled state.
    // The custom bezier values will be captured when the configuration is applied.
    interpolationGroup.setOnCheckedChangeListener(
        (group, checkedId) ->
            setViewGroupDescendantsEnabled(customContainer, checkedId == R.id.radio_custom));
  }
}
 
Example 7
Source File: TypeRecommendIndexPageAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 过滤条件的item
 */
public View getForumFilterItem(int position, View convertView) {
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.item_forum_filter_recomm, null);
    }
    RadioGroup group = ViewHolder.get(convertView, R.id.radio);

    int index = getHomePageIndex(position);
    final Recommend recommend = homePage.get(index).getRecommend();
    ArrayList<ThreadConfig> threadConfigItems = recommend.getThreadConfigs();

    int[] ids = {R.id.radioButton1, R.id.radioButton2, R.id.radioButton3, R.id.radioButton4};
    group.check(ids[recommend.getForumFilterSelectIndex()]);

    for (int i = 0; i < ids.length; i++) {
        RadioButton radioButton = ViewHolder.get(convertView, ids[i]);
        if (threadConfigItems != null && i < threadConfigItems.size()) {
            ThreadConfig item = threadConfigItems.get(i);
            radioButton.setVisibility(View.VISIBLE);
            radioButton.setText(getFilterItemTitle(item));
        } else {
            radioButton.setVisibility(View.GONE);
        }
        final int ii = i;
        radioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                filterItemClick(recommend, ii);
            }
        });
    }
    return convertView;
}
 
Example 8
Source File: NewSensorLocation.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_sensor_location);
    button = (Button)findViewById(R.id.saveSensorLocation);
    buttonCancel = (Button)findViewById(R.id.saveSensorLocationCancel);
    sensor_location_other = (EditText) findViewById(R.id.edit_sensor_location);
    sensor_location_other.setEnabled(false);
    DontAskAgain = (CheckBox)findViewById(R.id.sensorLocationDontAskAgain);
    radioGroup = (RadioGroup) findViewById(R.id.myRadioGroup);
    addListenerOnButton();

    locations = new LinkedList<Location>();

    locations.add(new Location("I don't wish to share", PRIVATE_ID));
    locations.add(new Location("Upper arm", 1));
    locations.add(new Location("Thigh", 2));
    locations.add(new Location("Belly (abdomen)", 3));
    locations.add(new Location("Lower back", 4));
    locations.add(new Location("Buttocks", 5));
    locations.add(new Location("Other", OTHER_ID));

    for(Location location : locations) {
        AddButton(location.location, location.location_id);
    }
    radioGroup.check(PRIVATE_ID);

}
 
Example 9
Source File: Dialog.java    From PocketMaps with MIT License 5 votes vote down vote up
public static void showUnitTypeSelector(Activity activity)
{
  AlertDialog.Builder builder1 = new AlertDialog.Builder(activity);
  builder1.setTitle(R.string.units);
  builder1.setCancelable(true);
  
  final RadioButton rb1 = new RadioButton(activity.getBaseContext());
  rb1.setText(R.string.units_metric);

  final RadioButton rb2 = new RadioButton(activity.getBaseContext());
  rb2.setText(R.string.units_imperal);
  
  final RadioGroup rg = new RadioGroup(activity.getBaseContext());
  rg.addView(rb1);
  rg.addView(rb2);
  rg.check(Variable.getVariable().isImperalUnit() ? rb2.getId() : rb1.getId());
  
  builder1.setView(rg);
  OnClickListener listener = new OnClickListener()
  {
    @Override
    public void onClick(DialogInterface dialog, int buttonNr)
    {
      Variable.getVariable().setImperalUnit(rb2.isChecked());
      Variable.getVariable().saveVariables(Variable.VarType.Base);
    }
  };
  builder1.setPositiveButton(R.string.ok, listener);
  AlertDialog alert11 = builder1.create();
  alert11.show();
}
 
Example 10
Source File: WrapLayoutActivity.java    From WrapLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wraplayout);
    Toolbar mToolbar = findViewById(R.id.wly_toolbar);
    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        }
    }
    lytWrap = findViewById(R.id.wly_lyt_warp);
    final RadioGroup rgGravity = findViewById(R.id.wly_rg_gravity);
    rgGravity.setOnCheckedChangeListener(this);
    rgGravity.check(R.id.wly_rb_top);
    final SeekBar sbHorizontal = findViewById(R.id.wly_sb_horizontal);
    sbHorizontal.setOnSeekBarChangeListener(this);
    sbHorizontal.setProgress(15);
    final SeekBar sbVertical = findViewById(R.id.wly_sb_vertical);
    sbVertical.setOnSeekBarChangeListener(this);
    sbVertical.setProgress(15);
}
 
Example 11
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void initButtonTypeRadioGroup() {
	buttonTypeRadioGroup = (RadioGroup) findViewById(R.id.fab_activity_radiogroup_button_type);
	switch (actionButton.getType()) {
		case DEFAULT:
			buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_default);
			break;
		case MINI:
			buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_mini);
			break;
		case BIG:
               buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_big);
               break;
	}
	buttonTypeRadioGroup.setOnCheckedChangeListener(new ButtonTypeChangeListener());
}
 
Example 12
Source File: FeedbackActivity.java    From zhizhihu with Apache License 2.0 5 votes vote down vote up
@NonNull
private FrameLayout createRadioGroupLayout(final String[] typeList, RadioGroup.OnCheckedChangeListener listener) {
    final List<RadioButton> rbList = new ArrayList<>();
    final RadioGroup radioGroup = new RadioGroup(this);
    radioGroup.setPadding(24, 24, 24, 24);
    for (int i = 0; i < typeList.length; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setText(typeList[i]);
        rbList.add(rb);
        radioGroup.addView(rb);
    }
    String curType = mFeedbackTypeTxt.getText().toString();
    for (RadioButton btn : rbList) {
        if (btn.getText().toString().equals(curType)) {
            radioGroup.check(btn.getId());
        }
    }
    radioGroup.setOnCheckedChangeListener(listener);
    FrameLayout frameLayout = new FrameLayout(this);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    lp.leftMargin = DimenUtil.dip2px(this, 24);
    lp.rightMargin = lp.leftMargin;
    frameLayout.addView(radioGroup, lp);
    return frameLayout;
}
 
Example 13
Source File: IRKitAccessPointSettingFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void setWifiStatus(Bundle savedInstanceState, View root) {
    EditText ssidText = (EditText) root.findViewById(R.id.inputSSID);
    EditText passwordText = (EditText) root.findViewById(R.id.inputPassword);
    RadioGroup radioGroup = (RadioGroup) root.findViewById(R.id.radioGroupSecurity);
    
    int typeId = -1;
    if (savedInstanceState != null) {
        ssidText.setText(savedInstanceState.getString(KEY_SSID));
        passwordText.setText(savedInstanceState.getString(KEY_PASS));
        typeId = savedInstanceState.getInt(KEY_TYPE);
    } else {
        
        IRKitSettingActivity a = (IRKitSettingActivity) getActivity();
        String ssid = a.getSSID();
        if (ssid == null) {
            ssid = WiFiUtil.getCurrentSSID(a);
        }
        
        ssidText.setText(ssid);
        passwordText.setText(a.getPassword());
        WiFiSecurityType type = a.getSecType();
        switch (type) {
        case NONE:
            typeId = R.id.radioButton1;
            break;
        case WEP:
            typeId = R.id.radioButton2;
            break;
        case WPA2:
        default:
            typeId = R.id.radioButton3;
            break;
        }
    }
    radioGroup.check(typeId);
}
 
Example 14
Source File: MainActivity.java    From HomeApplianceMall with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    viewPager = (ViewPager) findViewById(R.id.ViewPager_main);
    radioGroup = (RadioGroup) findViewById(R.id.RadioGroup_main);
    application = (MyApplication)getApplication();

    //viewPage
    List<Fragment> fragmentList = new ArrayList<>();
    HomeFragment homeFragment = new HomeFragment();
    SearchFragment searchFragment = new SearchFragment();
    ClassifyFragment classifyFragment = new ClassifyFragment();
    ShoppingCarFragment shoppingCarFragment = new ShoppingCarFragment();
    OrderFragment orderFragment = new OrderFragment();
    MyFragment myFragment = new MyFragment();
    fragmentList.add(homeFragment);
    fragmentList.add(searchFragment);
    fragmentList.add(classifyFragment);
    fragmentList.add(shoppingCarFragment);
    fragmentList.add(orderFragment);
    fragmentList.add(myFragment);
    application.setViewPager(viewPager);
    viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(),fragmentList));
    viewPager.setCurrentItem(0);
    viewPager.setOnPageChangeListener(new MyPageLister());

    //
    radioGroup.setOnCheckedChangeListener(new MyRadionGroupListen());
    radioGroup.check(R.id.radioButton_main_home);
    //
}
 
Example 15
Source File: SortDialog.java    From android-auto-call-recorder with MIT License 5 votes vote down vote up
private void checkArrangeRadioGroup(RadioGroup group, String arrange) {
    switch (arrange) {
        case " DESC":
            group.check(R.id.rb_arrange_desc);
            break;
        case " ASC":
            group.check(R.id.rb_arrange_asc);
            break;
    }
}
 
Example 16
Source File: ThermalCameraFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Update ActionBar
    setActionBarTitle(R.string.thermalcamera_tab_title);

    // UI
    mUartWaitingTextView = view.findViewById(R.id.uartWaitingTextView);
    RadioGroup colorModeRadioGroup = view.findViewById(R.id.colorModeRadioGroup);
    colorModeRadioGroup.check(mIsColorEnabled ? R.id.colorModeColorButton : R.id.colorModeMonochromeButton);
    colorModeRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> {
        mIsColorEnabled = i == R.id.colorModeColorButton;
        mThermalScaleView.updateGradient();
    });

    RadioGroup magnificationRadioGroup = view.findViewById(R.id.magnificationRadioGroup);
    magnificationRadioGroup.check(mIsFilterEnabled ? R.id.magnificationFilteredButton : R.id.magnificationPixelatedButton);
    magnificationRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> mIsFilterEnabled = i == R.id.magnificationFilteredButton);

    mCameraImageView = view.findViewById(R.id.cameraImageView);
    mLowerTempTextView = view.findViewById(R.id.lowerTempTextView);
    mUpperTempTextView = view.findViewById(R.id.upperTempTextView);
    mThermalScaleView = view.findViewById(R.id.thermalScaleView);
    mThermalScaleView.setThermalCameraFragment(this);

    // Setup
    Context context = getContext();
    if (context != null) {
        mUartDataManager = new UartDataManager(context, this, true);
        setupUart();
    }
}
 
Example 17
Source File: FABActivity.java    From fab with Apache License 2.0 4 votes vote down vote up
private void initButtonColorsRadioGroup() {
	buttonColorsRadioGroup = (RadioGroup) findViewById(R.id.fab_activity_radiogroup_colors);
	populateColorsRadioGroup(buttonColorsRadioGroup, RadioButtons.COLORS);
	buttonColorsRadioGroup.setOnCheckedChangeListener(new ColorChangeListener());
	buttonColorsRadioGroup.check(buttonColorsRadioGroup.getChildAt(0).getId());
}
 
Example 18
Source File: FABActivity.java    From fab with Apache License 2.0 4 votes vote down vote up
private void initStrokeColorRadioGroup() {
	strokeColorRadioGroup = (RadioGroup) findViewById(R.id.fab_activity_radiogroup_stroke);
	populateColorsRadioGroup(strokeColorRadioGroup, RadioButtons.STROKE_COLORS);
	strokeColorRadioGroup.setOnCheckedChangeListener(new ColorChangeListener());
	strokeColorRadioGroup.check(strokeColorRadioGroup.getChildAt(0).getId());
}
 
Example 19
Source File: ReencodingDialog.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Context context = getActivity();
	qualityForm = new SeekBarForm(false);
	qualityForm.setConfiguration(1, 100, 1, 1);
	qualityForm.setValueFormat(getString(R.string.text_quality_format));
	qualityForm.setCurrentValue(savedInstanceState != null ? savedInstanceState.getInt(EXTRA_QUALITY) : 100);
	reduceForm = new SeekBarForm(false);
	reduceForm.setConfiguration(1, 8, 1, 1);
	reduceForm.setValueFormat(getString(R.string.text_reduce_format));
	reduceForm.setCurrentValue(savedInstanceState != null ? savedInstanceState.getInt(EXTRA_REDUCE) : 1);
	int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding_view);
	View qualityView = qualityForm.inflate(context);
	qualityForm.getSeekBar().setSaveEnabled(false);
	qualityView.setPadding(qualityView.getPaddingLeft(), 0, qualityView.getPaddingRight(), padding / 2);
	View reduceView = reduceForm.inflate(context);
	reduceForm.getSeekBar().setSaveEnabled(false);
	reduceView.setPadding(reduceView.getPaddingLeft(), 0, reduceView.getPaddingRight(),
			reduceView.getPaddingBottom());
	radioGroup = new RadioGroup(context);
	radioGroup.setOrientation(RadioGroup.VERTICAL);
	radioGroup.setPadding(padding, padding, padding, padding / 2);
	radioGroup.setOnCheckedChangeListener(this);
	for (int i = 0; i < OPTIONS.length; i++) {
		RadioButton radioButton = new RadioButton(context);
		radioButton.setText(OPTIONS[i]);
		radioButton.setId(IDS[i]);
		radioGroup.addView(radioButton);
	}
	radioGroup.check(IDS[0]);
	LinearLayout linearLayout = new LinearLayout(context);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	FrameLayout qualityLayout = new FrameLayout(context);
	qualityLayout.setId(android.R.id.text1);
	qualityLayout.addView(qualityView);
	FrameLayout reduceLayout = new FrameLayout(context);
	reduceLayout.setId(android.R.id.text2);
	reduceLayout.addView(reduceView);
	linearLayout.addView(radioGroup, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.addView(qualityLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.addView(reduceLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	ScrollView scrollView = new ScrollView(context);
	scrollView.addView(linearLayout, ScrollView.LayoutParams.MATCH_PARENT,
			ScrollView.LayoutParams.WRAP_CONTENT);
	return new AlertDialog.Builder(context).setTitle(R.string.text_reencode_image)
			.setView(scrollView).setNegativeButton(android.R.string.cancel, null)
			.setPositiveButton(android.R.string.ok, this).create();
}
 
Example 20
Source File: ExportDialogFragment.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
protected Dialog createDialog() {
  FragmentActivity fragmentActivity = getActivity();
  accounts = AccountManager.get(fragmentActivity).getAccountsByType(Constants.ACCOUNT_TYPE);

  // Get views
  View view = fragmentActivity.getLayoutInflater().inflate(R.layout.export, null);
  exportTypeOptions = (Spinner) view.findViewById(R.id.export_type_options);
  exportGoogleMapsOptions = (RadioGroup) view.findViewById(R.id.export_google_maps_options);
  exportGoogleFusionTablesOptions = (RadioGroup) view.findViewById(
      R.id.export_google_fusion_tables_options);
  exportExternalStorageOptions = (RadioGroup) view.findViewById(
      R.id.export_external_storage_options);
  accountSpinner = (Spinner) view.findViewById(R.id.export_account);
  
  // Setup exportTypeOptions
  setupExportTypeOptions(fragmentActivity);

  // Setup exportGoogleMapsOptions
  boolean exportGoogleMapsPublic = PreferencesUtils.getBoolean(fragmentActivity,
      R.string.export_google_maps_public_key, PreferencesUtils.EXPORT_GOOGLE_MAPS_PUBLIC_DEFAULT);
  exportGoogleMapsOptions.check(
      exportGoogleMapsPublic ? R.id.export_google_maps_public : R.id.export_google_maps_unlisted);

  // Setup exportGoogleFusionTablesOptions
  boolean exportGoogleFusionTablesPublic = PreferencesUtils.getBoolean(fragmentActivity,
      R.string.export_google_fusion_tables_public_key,
      PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
  exportGoogleFusionTablesOptions.check(
      exportGoogleFusionTablesPublic ? R.id.export_google_fusion_tables_public
          : R.id.export_google_fusion_tables_private);

  // Setup exportExternalStorageOptions
  setExternalStorageOption(
      (RadioButton) view.findViewById(R.id.export_external_storage_kml), TrackFileFormat.KML);
  setExternalStorageOption(
      (RadioButton) view.findViewById(R.id.export_external_storage_gpx), TrackFileFormat.GPX);
  setExternalStorageOption(
      (RadioButton) view.findViewById(R.id.export_external_storage_csv), TrackFileFormat.CSV);
  setExternalStorageOption(
      (RadioButton) view.findViewById(R.id.export_external_storage_tcx), TrackFileFormat.TCX);
  TrackFileFormat trackFileFormat = TrackFileFormat.valueOf(PreferencesUtils.getString(
      fragmentActivity, R.string.export_external_storage_format_key,
      PreferencesUtils.EXPORT_EXTERNAL_STORAGE_FORMAT_DEFAULT));
  exportExternalStorageOptions.check(getExternalStorageFormatId(trackFileFormat));

  // Setup accountSpinner
  AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts);
  
  return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
      R.string.generic_cancel, null)
      .setPositiveButton(R.string.menu_export, new DialogInterface.OnClickListener() {
          @Override
        public void onClick(DialogInterface dialog, int which) {
          FragmentActivity context = getActivity();
          ExportType type = exportTypeOptionsList.get(
              exportTypeOptions.getSelectedItemPosition());
          TrackFileFormat format = null;

          PreferencesUtils.setString(context, R.string.export_type_key, type.name());
          if (type == ExportType.GOOGLE_MAPS) {
            PreferencesUtils.setBoolean(context, R.string.export_google_maps_public_key,
                exportGoogleMapsOptions.getCheckedRadioButtonId()
                == R.id.export_google_maps_public);
          } else if (type == ExportType.GOOGLE_FUSION_TABLES) {
            PreferencesUtils.setBoolean(context, R.string.export_google_fusion_tables_public_key,
                exportGoogleFusionTablesOptions.getCheckedRadioButtonId()
                == R.id.export_google_fusion_tables_public);
          } else if (type == ExportType.EXTERNAL_STORAGE) {
            format = getTrackFileFormat(exportExternalStorageOptions.getCheckedRadioButtonId());
            PreferencesUtils.setString(
                context, R.string.export_external_storage_format_key, format.name());
          }
          Account account;
          if (accounts.length == 0) {
            account = null;
          } else if (accounts.length == 1) {
            account = accounts[0];
          } else {
            account = accounts[accountSpinner.getSelectedItemPosition()];
          }
          AccountUtils.updateShareTrackAccountPreference(context, account);
          caller.onExportDone(type, format, account);
        }
      }).setTitle(R.string.export_title).setView(view).create();
}