我的应用程序崩溃了片段内列表视图中的onitemclick

时间:2018-12-04 10:40:31

标签: java android

我的片段和onitemclicklistener出现问题。当我运行该应用程序时,它会显示一个列表,但是当我单击该应用程序时会崩溃。有人可以看到发生这种现象的原因是什么?

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
    final View result = inflater.inflate(R.layout.fragment_movie, container, false);
    listView = (ListView) result.findViewById(R.id.list);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity(), MovieDetailActivity.class);
            intent.putExtra("MOVIE_DETAILS", (MovieDetails) parent.getItemAtPosition(position));
            startActivity(intent);

        }
    });

}
  

进程:com.vjezba.androidtab.tabswitch,PID:10943 android.content.ActivityNotFoundException:无法找到显式活动类{com.vjezba.androidtab.tabswitch / com.vjezba.androidtab.tabswitch.MovieDetailActivity};您是否在AndroidManifest.xml中声明了此活动?

1 个答案:

答案 0 :(得分:0)

请在您的Android Manifest内部应用标签中添加此标签:

        <activity
            android:name="com.vjezba.androidtab.tabswitch.MovieDetailActivity" />