Add CalendarView button to Google Maps API V2 - Android - 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.

Related

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>

how can i make some item always in list?

I want to make a history message list when I click customAutoCompleteTextView, and
I using BastAdapter made the red circle part
but I have no idea how to make "Clear All" item what that is always visible
, BTW I don't want to add a new item in history's list.
How can I do??
try this:
<?xml version="1.0" encoding="utf-8"?><!-- File created by SkillsOn -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<!--This could be anything that shows your Message list-->
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_below="#+id/clearAll"/>
<!--This is clearAll button and is always visible-->
<Button
android:id="#+id/clearAll"
android:text="Clear all"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</RelativeLayout>

Can't Identify which element is used....?

I've an android application, which set Location based reminders. After I added an alarm, it displays as following.
I can't understand which component is used to display the small map and text both. Also the small map has location which I've selected on the map. I'm developing similar application, and I want to use this type of display feature.
That looks like a Lite mode Google Map to me.
this video is the best explanation on the internet and covers the use case i think you are refering to.
https://youtu.be/N0N1Xkc_1pU
You can check out my answer to another similar question here: https://stackoverflow.com/a/39462819/3456841
Here's the google developers page on the topic
https://developers.google.com/maps/documentation/android-api/lite
Also here's a link to a demo activity that uses lite maps in a list
https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/src/main/java/com/example/mapdemo/LiteListDemoActivity.java
you probably want your list item layout file to look something like
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toLeftOf="#+id/map">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/created_at"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.MapFragment"
android:id="#+id/map"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
map:cameraZoom="13"
map:mapType="normal"
map:liteMode="true"/>
</RelativeLayout>
Note the map:liteMode="true" in the map fragment declaration.

How to disable google maps touch events through a layout? (android)

Here is a screenshot of my application
If I touch the legend content, I can still move the map or click markers through the legend layout. Here is my XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.MapsActivity" />
<LinearLayout
android:id="#+id/legend_popover"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="10dp"
android:background="#color/white"
android:orientation="vertical"
android:radius="7dp"
android:visibility="gone">
...
I don't want to disable the whole map, I want to disable gestures only on the legend popover. Thank you #antonio for the answer
Use this
mMapFragment.getView().setClickable(false);
Another decent way to achieve the same.
googleMap.getUiSettings().setAllGesturesEnabled(false);
Add android:clickable="true" to your legend_popover layout
If you're using Kotlin:
mapView.getMapAsync {
it.uiSettings.setAllGesturesEnabled(false)
}

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