我想在我的应用程序中创建一个onDateChanged方法。 这意味着,当我点击我的editText(也是datepicker)并选择日期时, 它会立即更改textview中的数据。
然而,由于我已完成编码,当我选择日期时,文本视图中没有显示任何内容。 我想知道为什么这会发生在我的代码中。 有人可以帮助我吗?
monthDate = (EditText)findViewById(R.id.month);
avgPrice = (TextView)findViewById(R.id.showavfPriceTV);
exFuel = (TextView)findViewById(R.id.showexFuelTV);
avgFC = (TextView)findViewById(R.id.showavgFCTV);
doneButton = (Button)findViewById(R.id.doneBTN);
exitButton = (Button)findViewById(R.id.exitBTN);
Bundle takeBundledData = getIntent().getExtras();
// First we need to get the bundle data that pass from the UndergraduateListActivity
bundleID = takeBundledData.getString("clickedID");
bundleDate = takeBundledData.getString("clickedDate");
bundlePrice = takeBundledData.getString("clickedPrice");
bundlePump = takeBundledData.getString("clickedPump");
bundleCost = takeBundledData.getString("clickedCost");
bundleOdometer = takeBundledData.getString("clickedOdometer");
bundlePreOdometer = takeBundledData.getString("clickedpreOdometer");
bundleFcon = takeBundledData.getString("clickedFCon");
Log.d("SUMMARY","bundle : "+ takeBundledData);
monthDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// showDialog(DATE_DIALOG_ID);
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(), "datePicker");
}
public void onDateChanged(DatePicker view, int year,int month, int day)
{
if (monthDate.getText().toString().equals(bundleDate))
{
Log.d("TRYINGOUT","date : "+ bundleDate);
avgPrice.setText(bundlePrice);
}
else
{
Intent intent=new Intent(getApplicationContext(),about.class);
startActivity(intent);
}
}
});