Android studio Date picker is missing the OK button - android

I have a problem with the date picker in android 6.0 Marshmallow.
The problem is a simple one, in landscape mode, i have the OK button missing.
Here are some images to demonstrate the problem. (It works perfectly with the time picker)
The problem on tablet and phone:
As you can see, i have a spinner on top, but removing it didn't help.
I dont have that problem on the system itself.Here on setting and set datetime it works fine:
Here is the layout for the date time fragment.
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/White"
android:orientation="vertical">
<Spinner
android:id="#+id/spinner_date_time_choice"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Spinner>
<TimePicker
android:id="#+id/time_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<DatePicker
android:id="#+id/date_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

Related

Simple UI - how to?

Using Android studio 3.1, and I have a strange problem, I can't edit my UI,
I enter the content_main.xml, using the design tab, blueprint, anything i drag to the blueprint is not appearing, I use the infer constraints, still not helping
this is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="53dp"
tools:layout_editor_absoluteY="168dp" />
</android.support.constraint.ConstraintLayout>
I would't recommand using the UI designer, you don't get the feeling of what you are really doing with it. You should learn how to directly edit the XML file, this isn't really harder and at least you know what you are doing.
You must drag the widget to the component tree
ver imagen

Two datepickers open at the same time Is it possible?

I need to enter an initial date and a final date similar to this application in IOs:
Gif video about IOs app
I'm thinking of using a DatePicker to enter the initial date and then another or the same for the final date.
But my boss wants to see both DatePicker at the same time for the start date and end date. Is that possible?
Or there is a way to do something similar to the video gif previously indicated.
Thanks
You could you use 2 datepickers like this below,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></DatePicker>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</DatePicker>
</LinearLayout>
</ScrollView>
</LinearLayout>

Programmatically change selecting view (hour/minute) in TimePicker

I am wondering how to change selecting view in TimePicker. For example: I am at minute view and click some button and view change to selecting hour.
.
I am using custom Timepicker class with TimePicker in layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
style="#style/AppTheme"
android:background="#color/colorPrimaryDark">
<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tp_timepicker"
android:layout_weight="1" />
</LinearLayout>
Since requesting focus on the text views of the time picker didn't work, I went with performing the click on them - worked for me!
TimePicker tp = parentView.findViewById(R.id.tp_timepicker)
View timePickerPart = tp.findViewById(Resources.getSystem().getIdentifier("hours", "id", "android"));
timePickerPart.performClick();
Also works for minutes instead of hours. May work for amPm, too.

Add CalendarView button to Google Maps API V2 - Android

I want to implement CalendarView / DatePicker button into my Google Map
How can i do it ?
On click of this button i want a small calendar to open and enable to pick a date from the calendar,when the date is picked i want to execute a function that i wrote.
Thank you !
**The area marked with red doesn't exist right now :
I want this button to open a datePicker
https://imagizer.imageshack.us/v2/390x695q90/633/VyWT4l.jpg
my activity xml right now looks like:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
You can edit your map view and add button to it like any other layout.
for example you can use this code for your activity layout.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FC0"
android:gravity="center" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Fixed Footer"
android:textColor="#000"
android:textSize="20sp" />
</RelativeLayout>
</FrameLayout>
after that you can use datepicker for showing a dialog to select date.
you can find a solution for it here http://www.mkyong.com/android/android-date-picker-example/
for calling a function after selecting date you can use onDateSet function of datepicker , so call your function inside of onDateSet
you can find more informations about it by reading the article that i shared link with you.

CalendarView, need sample

I'm building an application using CalendarView. My issue is, that I don't find the way to customize the calendar style.
This is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/calendario_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CalendarView
android:id="#+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
When I show this screen, I get the month's name and the year, like in the photo.
How can I customize the CalendarView style?
for designing the calendar you can try this Link
and change the
android:layout_height="wrap_content"
to
android:layout_height="match_parent"
this might also help you Link

Categories

Resources