我一直遇到一个错误,就是我刚创建的项目中这个类(DataProvider)似乎无法接受 .add 或者 .put 方法。但是我的 MainActivity 类可以很好地接受它们。我已经执行了“无效缓存和重启”操作。有人能解释一下为什么会出现这种情况以及我该如何解决吗?
DataProvider:
DataProvider:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class DataProvider {
public static HashMap<String, List<String>> getInfo()
HashMap<String, List<String>> MoviesDetails = new HashMap<String, List<String>>();
List<String> Action_Movies = new ArrayList<String>();
//'.add' would be an error in red. Cannot resolve symbol 'add'.
Action_Movies.add("");
List<String> Romantic_Movies = new ArrayList<String>();
Romantic_Movies.add("");
List<String> Horror_Movies = new ArrayList<String>();
Horror_Movies.add("");
List<String> Comedy_Movies = new ArrayList<String>();
Comedy_Movies.add("");
}
MainActivity:
import android.app.Activity;
import android.os.Bundle;
import android.widget.ExpandableListView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class MainActivity extends Activity {
HashMap<String, List<String>> Movies_categories;
List<String> Movies_list;
ExpandableListView Exp_list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<String> Test = new ArrayList<String>();
Test.add("Test");
}
}
List<String> actionMovies;
- Joseph Webber