我想要的是当我选择一个日期时,它会过滤rss Feed以显示所选日期的道路工程。只是现在我开始打算带我去下一个显示所有道路工程的活动,而不是当天选择的那些。我该怎么做呢?
public class ChooseDate extends Activity {
RelativeLayout rl;
Button pick;
DatePicker date;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.date_picker);
rl = (RelativeLayout) findViewById(R.id.rl);
pick = (Button) findViewById(R.id.button1);
date = new DatePicker (ChooseDate.this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams
((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
date.setLayoutParams(params);
rl.addView(date);
pick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "Date is : " +
date.getDayOfMonth() + "-"+(date.getMonth()+1) +
"-"+ date.getYear(), Toast.LENGTH_SHORT).show();
startActivity(new Intent("com.mobilerwts.robert.MainActivityOther"));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
答案 0 :(得分:1)
如果我理解这一点,您希望将日期从第一个活动传递到第二个活动。如果要这样做,则需要将其包含在Intent中。基本上,您必须在意图中包含数据。有关如何执行此操作,请参阅How do I pass data between Activities in Android application?。