作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个显示即将上映和正在播放的电影列表的电影管理器应用。
这里的错误是 Movie() 在 android.graphics.Movie 中不公开,不能从外部包访问。
请帮忙。
包 com.example.android.moviemanager.activity.fragments;
import android.graphics.Movie;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.android.moviemanager.R;
import com.example.android.moviemanager.activity.adapters.MovieRecyclerViewAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A simple {@link Fragment} subclass.
*/
public class now_playing extends Fragment {
@BindView(R.id.rvMovie)
RecyclerView rvMovie;
List<Movie> movies;
public now_playing() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_now_playing, container, false);
ButterKnife.bind(this, view);
initializeData();
LinearLayoutManager llm=new LinearLayoutManager(this.getContext());
rvMovie.setHasFixedSize(true);
rvMovie.setLayoutManager(llm);
MovieRecyclerViewAdapter adapter= new MovieRecyclerViewAdapter(getContext(), movies);
rvMovie.setAdapter(adapter);
return view;
}
private void initializeData() {
movies = new ArrayList<Movie>();
movies.add(new Movie("277834", "Moana", "In Ancient Polynesia, when a terrible curse incurred by Maui reaches an impetuous Chieftain's daughter's island, she answers the Ocean's call to seek out the demigod to set things right.", 6.5f, 854, "/z4x0Bp48ar3Mda8KiPD1vwSY3D8.jpg", "/1qGzqGUd1pa05aqYXGSbLkiBlLB.jpg"));
movies.add(new Movie("121856", "Passengers", "A spacecraft traveling to a distant colony planet and transporting thousands of people has a malfunction in its sleep chambers. As a result, two passengers are awakened 90 years early.", 6.2f, 745, "/5gJkVIVU7FDp7AfRAbPSvvdbre2.jpg", "/5EW4TR3fWEqpKsWysNcBMtz9Sgp.jpg"));
movies.add(new Movie("330459", "Assassin's Creed", "Lynch discovers he is a descendant of the secret Assassins society through unlocked genetic memories that allow him to relive the adventures of his ancestor, Aguilar, in 15th Century Spain. After gaining incredible knowledge and skills he’s poised to take on the oppressive Knights Templar in the present day.", 5.3f, 691, "/tIKFBxBZhSXpIITiiB5Ws8VGXjt.jpg", "/5EW4TR3fWEqpKsWysNcBMtz9Sgp.jpg"));
movies.add(new Movie("283366", "Rogue One: A Star Wars Story", "A rogue band of resistance fighters unite for a mission to steal the Death Star plans and bring a new hope to the galaxy.", 7.2f, 1802, "/qjiskwlV1qQzRCjpV0cL9pEMF9a.jpg", "/tZjVVIYXACV4IIIhXeIM59ytqwS.jpg"));
movies.add(new Movie("313369", "La La Land", "Mia, an aspiring actress, serves lattes to movie stars in between auditions and Sebastian, a jazz musician, scrapes by playing cocktail party gigs in dingy bars, but as success mounts they are faced with decisions that begin to fray the fragile fabric of their love affair, and the dreams they worked so hard to maintain in each other threaten to rip them apart.", 8, 396, "/la-la-land-ryan-gosling-emma-stone-600x413.jpg", "/nadTlnTE6DdgmYsN4iWc2a2wiaI.jpg"));
}
}
最佳答案
您有两个同名 Movie
的类,这就是编译器不理解您要引用哪个 Movie
类的原因。
请使用完整的 android.graphics.Movie
或 Your-Package-here.Movie
访问电影类。
但是,如果您重命名您的模型类 Movie
,那么此问题将得到解决。
关于android - Movie() 在 adroid.graphics.Movie 中不公开 无法从包外访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42899653/
我是一名优秀的程序员,十分优秀!