无法在活动之间导航

时间:2014-08-19 17:06:27

标签: android android-intent android-activity

我正在使用ListView和CustomBaseAdapter的ViewHolder实现。当我在listview上点击一个项目时,我正在尝试移动到另一个活动。

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

                // TODO Auto-generated method stubg
                Intent intent = new Intent(getApplicationContext(), NurseryRhymeDetailActivity.class);
                NurseryRhyme rhyme=(NurseryRhyme) parent.getItemAtPosition(1);

                intent.putExtra("title", rhyme.getTitle());
                intent.putExtra("description", rhyme.getDescription());
                startActivity(intent);
            }

        });

我收到ActivityNotFoundException异常。怎么解决这个问题?

NurseryRhymeDetailActivity的代码如下

public class NurseryRhymeDetailActivity extends ActionBarActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    //  setContentView(R.layout.details_activity);

        Intent intent = getIntent();
        String message = intent.getStringExtra("description");

        // Create the text view
        TextView textView = new TextView(this);
        textView.setTextSize(40);
        textView.setText(message);

        // Set the text view as the activity layout
        setContentView(textView);


    }


}

2 个答案:

答案 0 :(得分:1)

ActivityNotFoundException您是否已在AndroidManifest.xml

中宣布此活动

您必须将NurseryRhymeDetailActivity活动注册到Manifest.xml

答案 1 :(得分:1)

您是否已在AndroidManifest.xml中声明此活动?