问题
I know this question has already been asked and even answered, but I was unable to figure out much from the solution provided. I was trying to follow this tutorial but I could not figure out exactly what I need to do. I have already downloaded the Android-DatePicker library and changed the image in the drawable folder, but after that I could not perform the steps required.
I have this sample activity:
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());
}
}
}
What I want to do is that, I want the datepicker to open up when the user clicks on the pickDate button. Please tell me the steps to be done after this to achieve the goal. I want the divider color to be #009945.
来源:https://stackoverflow.com/questions/27544613/datepicker-divider-color-change-according-to-application-theme