本文整理了Java中android.view.Display.getName()
方法的一些代码示例,展示了Display.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Display.getName()
方法的具体详情如下:
包路径:android.view.Display
类名称:Display
方法名:getName
暂无
代码示例来源:origin: ACRA/acra
private void collectName(@NonNull Display display, @NonNull JSONObject container) throws JSONException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
container.put("name", display.getName());
}
}
代码示例来源:origin: square/assertj-android
@TargetApi(JELLY_BEAN_MR1)
public DisplayAssert hasName(String name) {
isNotNull();
String actualName = actual.getName();
assertThat(actualName) //
.overridingErrorMessage("Expected name <%s> but was <%s>", name, actualName) //
.isEqualTo(name);
return this;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void changedStateShouldApplyToOtherInstancesOfSameDisplay() throws Exception {
shadow.setName("another name");
shadow.setWidth(1024);
shadow.setHeight(600);
display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
assertEquals(1024, display.getWidth());
assertEquals(600, display.getHeight());
assertEquals("another name", display.getName());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldProvideWeirdDisplayInformation() {
shadow.setName("foo");
shadow.setFlags(123);
assertEquals("foo", display.getName());
assertEquals(123, display.getFlags());
display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
assertEquals(123, display.getFlags());
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(JELLY_BEAN_MR1)
public DisplayAssert hasName(String name) {
isNotNull();
String actualName = actual.getName();
assertThat(actualName) //
.overridingErrorMessage("Expected name <%s> but was <%s>", name, actualName) //
.isEqualTo(name);
return this;
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View v;
if (convertView == null) {
v = ((Activity) mContext).getLayoutInflater().inflate(
R.layout.presentation_list_item, null);
} else {
v = convertView;
}
final Display display = getItem(position);
final int displayId = display.getDisplayId();
CheckBox cb = (CheckBox)v.findViewById(R.id.checkbox_presentation);
cb.setTag(display);
cb.setOnCheckedChangeListener(PresentationActivity.this);
cb.setChecked(mActivePresentations.indexOfKey(displayId) >= 0
|| mSavedPresentationContents.indexOfKey(displayId) >= 0);
TextView tv = (TextView)v.findViewById(R.id.display_id);
tv.setText(v.getContext().getResources().getString(
R.string.presentation_display_id_text, displayId, display.getName()));
Button b = (Button)v.findViewById(R.id.info);
b.setTag(display);
b.setOnClickListener(PresentationActivity.this);
return v;
}
代码示例来源:origin: qiubiteme/android_api_demos
R.string.presentation_display_id_text, displayId, display.getName()));
代码示例来源:origin: googlesamples/android-BasicMediaRouter
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the content view to the custom layout
setContentView(R.layout.display);
// Get the Views
mLayout = (LinearLayout) findViewById(R.id.display_layout);
mText = (TextView) findViewById(R.id.display_text);
/*
* Show the name of the display this presentation was embedded in.
*/
TextView smallText = (TextView) findViewById(R.id.display_smalltext);
final String name = getDisplay().getName();
smallText.setText(getResources().getString(R.string.display_name, name));
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Get the resources for the context of the presentation.
// Notice that we are getting the resources from the context of the presentation.
Resources r = getContext().getResources();
// Inflate the layout.
setContentView(R.layout.presentation_content);
final Display display = getDisplay();
final int displayId = display.getDisplayId();
final int photo = mContents.photo;
// Show a caption to describe what's going on.
TextView text = (TextView)findViewById(R.id.text);
text.setText(r.getString(R.string.presentation_photo_text,
photo, displayId, display.getName()));
// Show a n image for visual interest.
ImageView image = (ImageView)findViewById(R.id.image);
image.setImageDrawable(r.getDrawable(PHOTOS[photo]));
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
// Set the background to a random gradient.
Point p = new Point();
getDisplay().getSize(p);
drawable.setGradientRadius(Math.max(p.x, p.y) / 2);
drawable.setColors(mContents.colors);
findViewById(android.R.id.content).setBackground(drawable);
}
}
代码示例来源:origin: li2/learning-android-open-source
@Override
protected void onCreate(Bundle savedInstanceState) {
// Be sure to call the super class.
super.onCreate(savedInstanceState);
// Get the resources for the context of the presentation.
// Notice that we are getting the resources from the context of the presentation.
Resources r = getContext().getResources();
// Inflate the layout.
setContentView(R.layout.presentation_content);
final Display display = getDisplay();
final int displayId = display.getDisplayId();
final int photo = mContents.photo;
// Show a caption to describe what's going on.
TextView text = (TextView)findViewById(R.id.text);
text.setText(r.getString(R.string.presentation_photo_text,
photo, displayId, display.getName()));
// Show a n image for visual interest.
ImageView image = (ImageView)findViewById(R.id.image);
image.setImageDrawable(r.getDrawable(PHOTOS[photo]));
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
// Set the background to a random gradient.
Point p = new Point();
getDisplay().getSize(p);
drawable.setGradientRadius(Math.max(p.x, p.y) / 2);
drawable.setColors(mContents.colors);
findViewById(android.R.id.content).setBackground(drawable);
}
}
代码示例来源:origin: li2/learning-android-open-source
private void updateContents() {
// Show either the content in the main activity or the content in the presentation
// along with some descriptive text about what is happening.
if (mPresentation != null) {
mInfoTextView.setText(getResources().getString(
R.string.presentation_with_media_router_now_playing_remotely,
mPresentation.getDisplay().getName()));
mSurfaceView.setVisibility(View.INVISIBLE);
mSurfaceView.onPause();
if (mPaused) {
mPresentation.getSurfaceView().onPause();
} else {
mPresentation.getSurfaceView().onResume();
}
} else {
mInfoTextView.setText(getResources().getString(
R.string.presentation_with_media_router_now_playing_locally,
getWindowManager().getDefaultDisplay().getName()));
mSurfaceView.setVisibility(View.VISIBLE);
if (mPaused) {
mSurfaceView.onPause();
} else {
mSurfaceView.onResume();
}
}
}
代码示例来源:origin: qiubiteme/android_api_demos
private void updateContents() {
// Show either the content in the main activity or the content in the presentation
// along with some descriptive text about what is happening.
if (mPresentation != null) {
mInfoTextView.setText(getResources().getString(
R.string.presentation_with_media_router_now_playing_remotely,
mPresentation.getDisplay().getName()));
mSurfaceView.setVisibility(View.INVISIBLE);
mSurfaceView.onPause();
if (mPaused) {
mPresentation.getSurfaceView().onPause();
} else {
mPresentation.getSurfaceView().onResume();
}
} else {
mInfoTextView.setText(getResources().getString(
R.string.presentation_with_media_router_now_playing_locally,
getWindowManager().getDefaultDisplay().getName()));
mSurfaceView.setVisibility(View.VISIBLE);
if (mPaused) {
mSurfaceView.onPause();
} else {
mSurfaceView.onResume();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!