我在清单中有这两项活动:
<activity android:name=".ProgressPhotos"
android:screenOrientation="portrait">
</activity>
<activity android:name=".DetailsActivity"
android:screenOrientation="portrait">
</activity>
我想在“进度照片”中单击的项目启动DetailsActivity:
public class DetailsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details_activity);
....
所以,在ProgressPhotos中,我在点击监听器上设置了这个:
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
ImageItem item = (ImageItem) parent.getItemAtPosition(position);
//Create intent
Intent viewDetails = new Intent(ProgressPhotos.this,DetailsActivity.class);
viewDetails.putExtra("title", item.getTitle());
viewDetails.putExtra("image", item.getImage());
//Start details activity
try {
startActivity(viewDetails);
}
catch (Exception e){
// log statement here
}
}
});
我在整个监听器中设置了断点。单击每个,并且永远不会抛出异常。
但是,DetailsActivity的onCreate 从不调用。它永远不会被启动,但每一行都被执行。怎么样?我尝试过改变&#34; ProgressPhotos.this&#34;获取应用程序上下文,以及相同的响应。不会抛出任何错误。会是什么呢?