当前位置: 代码迷 >> Android >> 【新手】使用全局对象出现Source Not Found异常
  详细解决方案

【新手】使用全局对象出现Source Not Found异常

热度:28   发布时间:2016-05-01 21:33:59.0
【新手求救】使用全局对象出现Source Not Found错误
我将全局对象放在ray.global.centa里,代码如下:
Java code
package ray.global.centa;import android.app.Application;public class Screen extends Application {        public int Screen_Width;    public int Screen_Heigh;    }


然后在另一个package里引用:
Java code
package ray.app.centa;import android.app.Activity;import android.os.Bundle;import android.util.DisplayMetrics;public class CentaPhoneAppActivity extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);                ray.global.centa.Screen screen = (ray.global.centa.Screen)getApplicationContext();        DisplayMetrics dm = new DisplayMetrics();        getWindowManager().getDefaultDisplay().getMetrics(dm);                //screen.Screen_Width = dm.widthPixels;        //screen.Screen_Width = dm.heightPixels;    }}

一运行结果就杯具了,出错,退出。调试后的错误信息是:Source Not Find

有劳各位大侠出手相助!谢谢!

------解决方案--------------------
manifest中,application设置了name属性了吗?
  相关解决方案