最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開發(fā)之日歷CalendarView用法示例

 更新時(shí)間:2019年03月18日 11:44:13   作者:水中魚之1999  
這篇文章主要介紹了Android開發(fā)之日歷CalendarView用法,簡(jiǎn)單分析了日歷CalendarView組件的功能、屬性設(shè)置方法、界面布局、事件監(jiān)聽等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android開發(fā)之日歷CalendarView用法。分享給大家供大家參考,具體如下:

簡(jiǎn)介:

1.CalendarView是安卓自帶的一個(gè)日歷控件

2.在主活動(dòng)中 通過(guò)設(shè)置setOnDataChangeListener() 來(lái)為其添加監(jiān)聽事件

可在其中獲得 洪湖所選擇的年月日的 詳細(xì)信息

實(shí)例:

 

基本設(shè)置方法:

1. 日歷的整體背景顏色 android:selectedWeekBackgroundColor="#aff"
2. 月份選擇部分的背景色 android:focusedMonthDateColor="#f00"
3. 顯示星期的背景色 android:weekSeparatorLineColor="#ff0"
4. 被選中的日期的背景色 android:unfocusedMonthDateColor="#f9f"

這里給出它的布局文件中的調(diào)用與配置:

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center_horizontal"
  android:orientation="vertical">
    <TextView
      android:text="please choose your birthday :"
      android:gravity="center"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:textSize="15dp"
      android:typeface="monospace"/>
    <!--1.設(shè)置以星期二為每周第一天-->
    <!--2.設(shè)置該組件總共顯示四個(gè)星期-->
    <!--3.并對(duì)該組件的星期盡心了定制-->
    <CalendarView
      android:id="@+id/calenderView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:firstDayOfWeek="3"
      android:shownWeekCount="4"
      android:selectedWeekBackgroundColor="#aff"
      android:focusedMonthDateColor="#f00"
      android:weekSeparatorLineColor="#ff0"
      android:unfocusedMonthDateColor="#f9f">
    </CalendarView>
</LinearLayout>

在主活動(dòng)中,為其添加監(jiān)聽事件后

可以通過(guò) day month dayOfMonth 來(lái)獲得用戶選擇的日期的具體信息:

public class MainActivity extends Activity {
  CalendarView calendarView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    calendarView = (CalendarView) findViewById(R.id.calenderView);
    //calendarView 監(jiān)聽事件
    calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
      @Override
      public void onSelectedDayChange( CalendarView view, int year, int month, int dayOfMonth) {
        //顯示用戶選擇的日期
        Toast.makeText(MainActivity.this,year + "年" + month + "月" + dayOfMonth + "日",Toast.LENGTH_SHORT).show();
      }
    });
  }
}

參考自瘋狂Android講義。

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見(jiàn)問(wèn)題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 深入探討Unit Testing in Android

    深入探討Unit Testing in Android

    本篇文章是對(duì)Unit Testing in Android進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • Android自定義View實(shí)現(xiàn)時(shí)鐘效果

    Android自定義View實(shí)現(xiàn)時(shí)鐘效果

    這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)時(shí)鐘效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Android App如何防止抓包

    Android App如何防止抓包

    我們要知道常用的抓包方式有Charles和Fiddler,他們通過(guò)在手機(jī)網(wǎng)絡(luò)中添加代理的方式,拿到App的請(qǐng)求,這篇文章主要給大家介紹了關(guān)于Android中App如何防止抓包的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • 使用Thumbnails實(shí)現(xiàn)圖片指定大小壓縮

    使用Thumbnails實(shí)現(xiàn)圖片指定大小壓縮

    這篇文章主要為大家詳細(xì)介紹了使用Thumbnails實(shí)現(xiàn)圖片指定大小壓縮,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08
  • Android如何快速適配暗黑模式詳解

    Android如何快速適配暗黑模式詳解

    微信在前段時(shí)間的更新中也實(shí)現(xiàn)了暗黑模式,而蘋果系統(tǒng)也早就支持暗黑模式,Android也一樣可以實(shí)現(xiàn),下面這篇文章主要給大家介紹了關(guān)于Android如何快速適配暗黑模式的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • Android開發(fā)之?dāng)?shù)據(jù)的存儲(chǔ)方式詳解

    Android開發(fā)之?dāng)?shù)據(jù)的存儲(chǔ)方式詳解

    本篇文章主要介紹了Android開發(fā)之?dāng)?shù)據(jù)的存儲(chǔ)方式,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。
    2016-11-11
  • android仿微信聯(lián)系人索引列表功能

    android仿微信聯(lián)系人索引列表功能

    這篇文章主要為大家詳細(xì)介紹了android仿微信聯(lián)系人索引列表功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • Android中毛玻璃效果的兩種實(shí)現(xiàn)代碼

    Android中毛玻璃效果的兩種實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android中毛玻璃效果的兩種實(shí)現(xiàn)代碼,第一種是使用JAVA算法FastBlur實(shí)現(xiàn),第二種是使用Android自帶類RenderScript 實(shí)現(xiàn),本文通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友參考下吧
    2024-08-08
  • Android?Service啟動(dòng)綁定流程詳解

    Android?Service啟動(dòng)綁定流程詳解

    這篇文章主要為大家介紹了Android?Service啟動(dòng)綁定流程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • kotlin開發(fā)cli工具小技巧詳解

    kotlin開發(fā)cli工具小技巧詳解

    這篇文章主要為大家介紹了kotlin開發(fā)cli工具小技巧詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12

最新評(píng)論

光山县| 阿克| 临夏县| 汝州市| 巴东县| 安阳县| 柘城县| 巍山| 巴里| 荆门市| 寿阳县| 电白县| 方山县| 江油市| 广水市| 南宫市| 张家港市| 化德县| 舞阳县| 屏边| 高密市| 玉树县| 曲沃县| 保德县| 阿克| 临漳县| 华亭县| 康保县| 南华县| 高州市| 邵东县| 河南省| 莱阳市| 讷河市| 江城| 英吉沙县| 大埔县| 邳州市| 建水县| 漳平市| 台东市|