在尝试运行我的Android应用程序时,收到以下错误消息:
public static class ListViewAdapter extends ArrayAdapter<ToDoItem>
^
symbol: class ToDoItem
location: class MainActivity
我花了最后五个小时来测试各种各样的事情,并向我大学的其他学生寻求帮助,但仍未找到解决方案。
在MainActivity.java中:
package androidlab.exercise4_1;
import androidlab.exercise4_1.MainActivity.ListViewAdapter.ToDoItemViewHolder;
import androidlab.exercise4_1.model.ToDoItem;
public class MainActivity extends Activity {
public static class ListViewAdapter extends ArrayAdapter<ToDoItem>
implements OnCreateContextMenuListener {
...
}
...
}
在ToDoItem.java中:
package androidlab.exercise4_1.model;
public class ToDoItem {
...
}
这里要求的是我的gradle文件:
build.gradle(项目:exercise4_1)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "androidlab.exercise4_1"
minSdkVersion 22
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
implementation 'com.android.support:support-v4:26.0.0-alpha1'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
}
答案 0 :(得分:1)
问题解决了,导入顺序错误。
必须是
test[, cycle := cumsum(level > shift(level, fill = first(level))), by = "id"]
x <- test[, .(start = min(time),
recharge = max(time),
diffcharge = max(level) - min(level)),
by = .(id, cycle)]
x[, difftime := as.numeric(recharge - start)]
x[, rate := diffcharge / difftime]
x
# id cycle start recharge diffcharge difftime rate
# 1: 1 0 2017-12-25 14:10:03 2017-12-25 16:00:04 21 110.01283 0.1908868
# 2: 1 1 2017-12-25 16:10:04 2017-12-25 17:20:03 16 69.98285 0.2286274
# 3: 2 0 2017-12-25 17:30:03 2017-12-25 19:00:03 89 89.99613 0.9889314
# 4: 2 1 2017-12-25 19:10:04 2017-12-25 20:10:03 13 59.99771 0.2166749
# 5: 2 2 2017-12-25 20:20:04 2017-12-25 20:40:03 3 19.99584 0.1500312
而不是
import androidlab.exercise4_1.model.ToDoItem;
import androidlab.exercise4_1.MainActivity.ListViewAdapter.ToDoItemViewHolder;
答案 1 :(得分:0)
编译器经常遇到嵌套类的问题。你的代码似乎是对的。 尝试创建一个新的类文件并外包该类。