本文整理了Java中android.app.Dialog.getContext()
方法的一些代码示例,展示了Dialog.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dialog.getContext()
方法的具体详情如下:
包路径:android.app.Dialog
类名称:Dialog
方法名:getContext
暂无
代码示例来源:origin: gzu-liyujiang/AndroidPicker
public Context getContext() {
return dialog.getContext();
}
代码示例来源:origin: robolectric/robolectric
public void clickOnText(int textId) {
if (inflatedView == null) {
inflatedView = LayoutInflater.from(context).inflate(layoutId, null);
}
String text = realDialog.getContext().getResources().getString(textId);
if (!clickOnText(inflatedView, text)) {
throw new IllegalArgumentException("Text not found: " + text);
}
}
代码示例来源:origin: stackoverflow.com
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog)
.setIcon(R.drawable.ic)
.setMessage(R.string.dialog_msg);
//The tricky part
Dialog d = builder.show();
int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = d.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.my_color));
代码示例来源:origin: seven332/EhViewer
public static void hideSoftInput(Dialog dialog) {
View view = dialog.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}
代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android
/**
* 关闭dialog中打开的键盘
*
* @param dialog
*/
public static void closeKeyboard(Dialog dialog) {
View view = dialog.getWindow().peekDecorView();
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
代码示例来源:origin: novoda/android-demos
public LeftNavBar(Dialog dialog) {
initialize(dialog.getWindow(), dialog.getContext());
}
代码示例来源:origin: KeepSafe/TapTargetView
public static TapTargetView showFor(Dialog dialog, TapTarget target, Listener listener) {
if (dialog == null) throw new IllegalArgumentException("Dialog is null");
final Context context = dialog.getContext();
final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.type = WindowManager.LayoutParams.TYPE_APPLICATION;
params.format = PixelFormat.RGBA_8888;
params.flags = 0;
params.gravity = Gravity.START | Gravity.TOP;
params.x = 0;
params.y = 0;
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
final TapTargetView tapTargetView = new TapTargetView(context, windowManager, null, target, listener);
windowManager.addView(tapTargetView, params);
return tapTargetView;
}
代码示例来源:origin: seven332/EhViewer
private void bind(Pair<String, String>[] data) {
if (null == mDialog || null == mProgressView || null == mErrorText || null == mListView) {
return;
}
if (0 == data.length) {
mProgressView.setVisibility(View.GONE);
mErrorText.setVisibility(View.VISIBLE);
mListView.setVisibility(View.GONE);
mErrorText.setText(R.string.no_archives);
} else {
String[] nameArray = new String[data.length];
for (int i = 0, n = data.length; i < n; i++) {
nameArray[i] = data[i].second;
}
mProgressView.setVisibility(View.GONE);
mErrorText.setVisibility(View.GONE);
mListView.setVisibility(View.VISIBLE);
mListView.setAdapter(new ArrayAdapter<>(mDialog.getContext(), R.layout.item_select_dialog, nameArray));
}
}
代码示例来源:origin: seven332/EhViewer
private void bind(Pair<String, String>[] data) {
if (null == mDialog || null == mProgressView || null == mErrorText || null == mListView) {
return;
}
if (0 == data.length) {
mProgressView.setVisibility(View.GONE);
mErrorText.setVisibility(View.VISIBLE);
mListView.setVisibility(View.GONE);
mErrorText.setText(R.string.no_torrents);
} else {
String[] nameArray = new String[data.length];
for (int i = 0, n = data.length; i < n; i++) {
nameArray[i] = data[i].second;
}
mProgressView.setVisibility(View.GONE);
mErrorText.setVisibility(View.GONE);
mListView.setVisibility(View.VISIBLE);
mListView.setAdapter(new ArrayAdapter<>(mDialog.getContext(), R.layout.item_select_dialog, nameArray));
}
}
代码示例来源:origin: androidquery/androidquery
AQuery aq = new AQuery(pd.getContext());
代码示例来源:origin: androidquery/androidquery
AQuery aq = new AQuery(pd.getContext());
代码示例来源:origin: sjwall/MaterialTapTargetPrompt
@NonNull
@Override
public Context getContext()
{
return mDialog.getContext();
}
}
代码示例来源:origin: sjwall/MaterialTapTargetPrompt
@Test
public void testGetContext()
{
final Dialog dialog = mock(Dialog.class);
final Activity activity = mock(Activity.class);
final Context context = mock(Context.class);
final DialogResourceFinder resourceFinder = new DialogResourceFinder(dialog);
when(dialog.getOwnerActivity()).thenReturn(activity);
when(dialog.getContext()).thenReturn(context);
assertEquals(context, resourceFinder.getContext());
}
}
代码示例来源:origin: stackoverflow.com
Dialog dialog; // your dialog
Context context = dialog.getContext();
if(context instanceof ContextWrapper)
{
context = ((ContextWrapper)context).getBaseContext();
}
return context;
代码示例来源:origin: stackoverflow.com
DialogInterface.OnClickListener foo = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
Dialog dialog = (Dialog) dialogInterface;
Context context = dialog.getContext();
// do some work with context
}
};
代码示例来源:origin: stackoverflow.com
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.alertdialog_caseadd);
//this method help me for title color change
dialog.setTitle(Html.fromHtml("<font color='#FFFFFF'>Add new case stage</font>"));
//this method help me for divider color change
int dividerId = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = dialog.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.white));
代码示例来源:origin: stackoverflow.com
Dialog d = getDialog();
d.setTitle(Html.fromHtml("<font color='#EC407A'>About</font>"));
int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = d.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
代码示例来源:origin: Meiqia/MeiqiaSDK-Android
/**
* 关闭dialog中打开的键盘
*
* @param dialog
*/
public static void closeKeyboard(Dialog dialog) {
View view = dialog.getWindow().peekDecorView();
if (view != null) {
InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
代码示例来源:origin: org.robolectric/framework
public void clickOnText(int textId) {
if (inflatedView == null) {
inflatedView = LayoutInflater.from(context).inflate(layoutId, null);
}
String text = realDialog.getContext().getResources().getString(textId);
if (!clickOnText(inflatedView, text)) {
throw new IllegalArgumentException("Text not found: " + text);
}
}
代码示例来源:origin: com.github.japgolly.android.test/robolectric
@Implementation
public Window getWindow() {
if (window == null) {
window = new TestWindow(realDialog.getContext());
}
return window;
}
内容来源于网络,如有侵权,请联系作者删除!