Datepicker divider color change according to application theme

余生长醉 提交于 2019-12-11 23:55:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!