我知道这个问题已被提出,甚至已经回答,但我无法从提供的解决方案中找到很多。我试图关注this教程,但我无法弄明白我需要做什么。我已经下载了Android-DatePicker库并更改了drawable
文件夹中的图片,但之后我无法执行所需的步骤。
我有示例活动:
import java.util.Calendar;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import net.simonvt.datepicker.DatePickerDialog;
import net.simonvt.datepicker.DatePickerDialog.OnDateSetListener;
import net.simonvt.datepicker.DatePicker;
public class SettingsActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings_portrait);
Button pickDate = (Button) findViewById(R.id.button1);
pickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
System.out.println("the selected " + mDay);
DatePickerDialog dialog = new DatePickerDialog(SettingsActivity.this, new mDateSetListener(), mYear, mMonth, mDay);
dialog.show();
}
});
};
class mDateSetListener implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
// getCalender();
int mYear = year;
int mMonth = monthOfYear;
int mDay = dayOfMonth;
// v.setText(new StringBuilder()
// // Month is 0 based so add 1
// .append(mMonth + 1).append("/").append(mDay).append("/")
// .append(mYear).append(" "));
// System.out.println(v.getText().toString());
}
}
}
我想要做的是,我想在用户点击pickDate
按钮时打开日期选择器。请告诉我在此之后要完成目标的步骤。我希望分隔符颜色为#009945
。