我想要多个应用程序类来清理我的代码。
所以我创建了4个类。
1.未来参考的一般类别:
public class GlobalVariables extends Application {
}
我的时间功能的时间表:
public class SetZmanim extends GlobalVariables {
static double latitude, longitude, elevation;
static String locationName;
static TimeZone timeZone;
static GeoLocation location;
static ComplexZmanimCalendar czc;
public void setZmanimAPI() {
locationName = "Queens, NY";
latitude = 40.725058; //Lakewood, NJ
longitude = -73.815653; //Lakewood, NJ
elevation = 0; //optional elevation
timeZone = TimeZone.getTimeZone("America/New_York");
location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
czc = new ComplexZmanimCalendar(location);
}
}
和4的实现方式与扩展原始类
这是我的清单:
<application
android:name=".GlobalVariables"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.edonfreiner.siddur/com.example.edonfreiner.siddur.MainActivity}: java.lang.ClassCastException: com.example.edonfreiner.siddur.GlobalVariables cannot be cast to com.example.edonfreiner.siddur.SetStyles
失败的部分:
SetStyles setStyles;
setStyles = ((SetStyles) this.getApplication());