use of android.widget.RadioButton in project Neuronizer by djuelg.
the class TodoListAppWidgetConfigure method createRadioButtons.
private void createRadioButtons() {
for (int i = 0; i < todoLists.length; i++) {
radioButtons[i] = new RadioButton(this);
radioButtons[i].setText(todoLists[i].getTitle());
radioGroup.addView(radioButtons[i]);
}
if (todoLists.length > 0) {
((RadioButton) radioGroup.getChildAt(0)).setChecked(true);
} else {
cancelWidgetCreation();
}
}
use of android.widget.RadioButton in project android2 by aqi00.
the class LaunchFragment method onCreateView.
// 创建碎片视图
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// 获取活动页面的上下文
mContext = getActivity();
if (getArguments() != null) {
// 如果碎片携带有包裹,则打开包裹获取参数信息
mPosition = getArguments().getInt("position", 0);
mImageId = getArguments().getInt("image_id", 0);
}
// 根据布局文件item_launch.xml生成视图对象
mView = inflater.inflate(R.layout.item_launch, container, false);
ImageView iv_launch = mView.findViewById(R.id.iv_launch);
RadioGroup rg_indicate = mView.findViewById(R.id.rg_indicate);
Button btn_start = mView.findViewById(R.id.btn_start);
// 设置引导页的全屏图片
iv_launch.setImageResource(mImageId);
// 每张图片都分配一个对应的单选按钮RadioButton
for (int j = 0; j < mCount; j++) {
RadioButton radio = new RadioButton(mContext);
radio.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
radio.setButtonDrawable(R.drawable.launch_guide);
radio.setPadding(10, 10, 10, 10);
// 把单选按钮添加到底部指示器的单选组
rg_indicate.addView(radio);
}
// 当前位置的单选按钮要高亮显示,比如第二个引导页就高亮第二个单选按钮
((RadioButton) rg_indicate.getChildAt(mPosition)).setChecked(true);
// 如果是最后一个引导页,则显示入口按钮,以便用户点击按钮进入首页
if (mPosition == mCount - 1) {
btn_start.setVisibility(View.VISIBLE);
btn_start.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "欢迎您开启美好生活", Toast.LENGTH_SHORT).show();
}
});
}
// 返回该碎片的视图对象
return mView;
}
use of android.widget.RadioButton in project afwall by ukanth.
the class LocaleEdit method finish.
@Override
public void finish() {
if (mIsCancelled) {
setResult(RESULT_CANCELED);
} else {
RadioGroup group = (RadioGroup) findViewById(R.id.radioProfiles);
int selectedId = group.getCheckedRadioButtonId();
RadioButton radioButton = (RadioButton) findViewById(selectedId);
String action = radioButton.getText().toString();
final Intent resultIntent = new Intent();
if (!G.isProfileMigrated()) {
int idx = group.indexOfChild(radioButton);
resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, PluginBundleManager.generateBundle(getApplicationContext(), idx + "::" + action));
} else {
resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, PluginBundleManager.generateBundle(getApplicationContext(), selectedId + "::" + action));
}
resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, action);
setResult(RESULT_OK, resultIntent);
}
super.finish();
}
use of android.widget.RadioButton in project Android-Password-Store by zeapo.
the class AutofillFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// this fragment is only created from the settings page (AutofillPreferenceActivity)
// need to interact with the recyclerAdapter which is a member of activity
final AutofillPreferenceActivity callingActivity = (AutofillPreferenceActivity) getActivity();
LayoutInflater inflater = callingActivity.getLayoutInflater();
@SuppressLint("InflateParams") final View view = inflater.inflate(R.layout.fragment_autofill, null);
builder.setView(view);
final String packageName = getArguments().getString("packageName");
final String appName = getArguments().getString("appName");
isWeb = getArguments().getBoolean("isWeb");
// set the dialog icon and title or webURL editText
String iconPackageName;
if (!isWeb) {
iconPackageName = packageName;
builder.setTitle(appName);
view.findViewById(R.id.webURL).setVisibility(View.GONE);
} else {
iconPackageName = "com.android.browser";
builder.setTitle("Website");
((EditText) view.findViewById(R.id.webURL)).setText(packageName);
}
try {
builder.setIcon(callingActivity.getPackageManager().getApplicationIcon(iconPackageName));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
// set up the listview now for items added by button/from preferences
adapter = new ArrayAdapter<String>(getActivity().getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1) {
// set text color to black because default is white...
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.grey_black_1000));
return textView;
}
};
((ListView) view.findViewById(R.id.matched)).setAdapter(adapter);
// delete items by clicking them
((ListView) view.findViewById(R.id.matched)).setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
adapter.remove(adapter.getItem(position));
}
});
// set the existing preference, if any
SharedPreferences prefs;
if (!isWeb) {
prefs = getActivity().getApplicationContext().getSharedPreferences("autofill", Context.MODE_PRIVATE);
} else {
prefs = getActivity().getApplicationContext().getSharedPreferences("autofill_web", Context.MODE_PRIVATE);
}
String preference = prefs.getString(packageName, "");
switch(preference) {
case "":
((RadioButton) view.findViewById(R.id.use_default)).toggle();
break;
case "/first":
((RadioButton) view.findViewById(R.id.first)).toggle();
break;
case "/never":
((RadioButton) view.findViewById(R.id.never)).toggle();
break;
default:
((RadioButton) view.findViewById(R.id.match)).toggle();
// trim to remove the last blank element
adapter.addAll(preference.trim().split("\n"));
}
// add items with the + button
View.OnClickListener matchPassword = new View.OnClickListener() {
@Override
public void onClick(View v) {
((RadioButton) view.findViewById(R.id.match)).toggle();
Intent intent = new Intent(getActivity(), PasswordStore.class);
intent.putExtra("matchWith", true);
startActivityForResult(intent, MATCH_WITH);
}
};
view.findViewById(R.id.matchButton).setOnClickListener(matchPassword);
// write to preferences when OK clicked
builder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setNegativeButton(R.string.dialog_cancel, null);
final SharedPreferences.Editor editor = prefs.edit();
if (isWeb) {
builder.setNeutralButton(R.string.autofill_apps_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (callingActivity.recyclerAdapter != null && packageName != null && !packageName.equals("")) {
editor.remove(packageName);
callingActivity.recyclerAdapter.removeWebsite(packageName);
editor.apply();
}
}
});
}
return builder.create();
}
use of android.widget.RadioButton in project iNaturalistAndroid by inaturalist.
the class ObservationViewerActivity method checkForTaxonDisagreement.
private void checkForTaxonDisagreement(int taxonId, String name, String scientificName, final onDisagreement cb) {
if ((mTaxonJson == null) || (mObsJson == null)) {
// We don't have the JSON structures for the observation and the taxon - cannot check for possible disagreement
cb.onDisagreement(false);
return;
}
BetterJSONObject taxon = new BetterJSONObject(mTaxonJson);
int communityTaxonId = taxon.getInt("id");
JSONArray ancestors = taxon.getJSONArray("ancestor_ids").getJSONArray();
// See if the current ID taxon is an ancestor of the current observation taxon / community taxon
boolean disagreement = false;
for (int i = 0; i < ancestors.length(); i++) {
int currentTaxonId = ancestors.optInt(i);
if (currentTaxonId == taxonId) {
disagreement = true;
break;
}
}
if ((!disagreement) || (communityTaxonId == taxonId)) {
// No disagreement here
cb.onDisagreement(false);
return;
}
// Show disagreement dialog
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup dialogContent = (ViewGroup) inflater.inflate(R.layout.explicit_disagreement, null, false);
TextView questionText = (TextView) dialogContent.findViewById(R.id.question);
final RadioButton disagreementRadioButton = (RadioButton) dialogContent.findViewById(R.id.disagreement);
final RadioButton noDisagreemenRadioButton = (RadioButton) dialogContent.findViewById(R.id.no_disagreement);
String taxonName = String.format("%s (%s)", name, scientificName);
String communityTaxonName = String.format("%s (%s)", TaxonUtils.getTaxonName(this, taxon.getJSONObject()), TaxonUtils.getTaxonScientificName(taxon.getJSONObject()));
/*
questionText.setText(Html.fromHtml(String.format(getString(R.string.do_you_think_this_could_be), taxonName)));
noDisagreemenRadioButton.setText(Html.fromHtml(String.format(getString(R.string.i_dont_know_but), scientificName)));
disagreementRadioButton.setText(Html.fromHtml(String.format(getString(R.string.i_am_sure_that_this_is_not), communityTaxonName)));
*/
questionText.setText(Html.fromHtml(String.format(getString(R.string.do_you_think_this_could_be), communityTaxonName)));
noDisagreemenRadioButton.setText(Html.fromHtml(String.format(getString(R.string.i_dont_know_but), taxonName)));
disagreementRadioButton.setText(Html.fromHtml(String.format(getString(R.string.i_am_sure_that_this_is_not), taxonName)));
mHelper.confirm(getString(R.string.potential_disagreement), dialogContent, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean isDisagreement = disagreementRadioButton.isChecked();
cb.onDisagreement(isDisagreement);
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Canceled dialog - nothing to do here
}
}, R.string.submit, R.string.cancel);
}
Aggregations