简体   繁体   中英

Eclipse doesn't recognize Display object

When I write this code:

Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics size = new DisplayMetrics();
display.

Eclipse doesn't pop up the functions of my display object. It shows these (new, nls, runnable, toarray) only:

How can I solve?

EDIT: Here are my imports:

import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

If you have updated to Eclipse Kepler recently (or perhaps, even if you haven't!), make sure "Java Proposals" is ticked under "Java/Editor/Content Assist/Advanced"

在此输入图像描述

EDIT : I did not notice that your code block was not within any method and just in the body of your class. Move it into onCreate() or some other lifecycle method and it will work.

这里有一些关于这些问题的好解决方案......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM