一切正常,除了这个活动给出resultCode = -1
public class SetTimeDialog extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settimedialog); Button bUseTime = (Button) findViewById(R.id.buttonUseTime_settime); bUseTime.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent resultIntent = new Intent(this,SetTimeDialog.class); setResult(Activity.RESULT_OK,resultIntent); finish(); } });
它在MainActivity中从这里调用:
TableLayout tiMetable = (TableLayout)findViewById(R.id.tiMetable_writepos); tiMetable.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v,MotionEvent event) { Intent settimedialogIntent = new Intent(getApplicationContext(),SetTimeDialog.class); startActivityForResult(settimedialogIntent,SETTIMEDIALOG_REQCODE); // See onActivityResult() return false; } });
在我的onActivityResult方法中,我现在什么都不做,只检查resultCode的值. (我已经删除了所有其他代码以找出错误).
解决方法
你知道RESULT_OK的值是-1吗?