Inflate android DatePickerDialog title.setCustomView with xml-ThrowExceptions

Exception or error:

Is there a provision to inflate android DatePickerDialog title.setCustomView with an xml file? Here what I need is either I want to inflate a layout to show title “SELECT FROM DATE” otherwise I want to reduce the size of selected date text ie;” Mon, Feb 17″.
This is what I have implemented now. ie; using dynamic view

         TextView tv = new TextView(this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, 
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        tv.setLayoutParams(lp);
        tv.setGravity(Gravity.CENTER);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
        tv.setPadding(0,20,0,20);
        tv.setText("SELECT FROM DATE");
        tv.setTextColor(getResources().getColor(R.color.mdtp_white));
        tv.setBackgroundColor(getResources().getColor(R.color.app_blue));
        mDatePicker.setCustomTitle(tv);
        mDatePicker.show();

Date picker

Any help will be appreciated.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *