我正在使用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);
}
}
答案 0 :(得分:1)
ActivityNotFoundException
您是否已在AndroidManifest.xml
?
您必须将NurseryRhymeDetailActivity
活动注册到Manifest.xml
答案 1 :(得分:1)
您是否已在AndroidManifest.xml中声明此活动?