آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

پیاده سازی تقویم

miladjalali.ir  8 سال پیش  8 سال پیش
+1 0

سلام

وقت به خیر

چجوری باید یه چنین چیزی پیاده سازی کرد؟

کتابخونه خاصی میشناسید دوستان؟

ممنون

0 0
سلام دوست عزیز : این لینک میتونه کمک کنه: لینک (8 سال پیش)
0 0
همچنین این : لینک (8 سال پیش)
0 0
این هم یک مدل سادست: لینک (8 سال پیش)
0 0
این هم یک ویجت می باشد: لینک (8 سال پیش)
 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
Borhani  8 سال پیش
+1 0

Open the android studio start the new project.

Android

Step 2

Put the application name and company domain. If you wish to use c++ for code the project , mark the Include c++ support then click next.

Android

Step 3

Select the android minimum SDK. After you chose the minimum SDK it will show approximate percentage of people use the that sdk then click next.

Android

Step 4

Choose the basic activity then click next.

Android

Step 5

Put the activity name and layout name. Android studio basically takes the java class name is what you provide the activity name and click finish.

Android

Step 6

Go to activity_main.xml then click the text bottom. This xml file contains the designing code for android app. Into the activity_main.xml copy and paste the below code.

Activity_main.xml code

 

 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"  
  4.     xmlns:tools="http://schemas.android.com/tools"  
  5.     android:layout_width="match_parent"  
  6.     android:layout_height="match_parent"  
  7.     tools:context="ganeshannt.calendarview.MainActivity">  
  8.   
  9.     <TextView  
  10.         android:id="@+id/date"  
  11.         android:layout_width="0dp"  
  12.         android:layout_height="51dp"  
  13.         android:text="Date"  
  14.         android:textAlignment="center"  
  15.         android:textSize="45dp"  
  16.         android:visibility="visible"  
  17.         app:layout_constraintBottom_toBottomOf="parent"  
  18.         app:layout_constraintHorizontal_bias="0.0"  
  19.         app:layout_constraintLeft_toLeftOf="parent"  
  20.         app:layout_constraintRight_toRightOf="parent"  
  21.         app:layout_constraintTop_toTopOf="parent"  
  22.         app:layout_constraintVertical_bias="0.219" />  
  23.   
  24.     <Button  
  25.         android:id="@+id/btngocalendar"  
  26.         android:layout_width="266dp"  
  27.         android:layout_height="47dp"  
  28.         android:text="Go to calendar"  
  29.         tools:layout_editor_absoluteX="47dp"  
  30.         tools:layout_editor_absoluteY="8dp" />  
  31.   
  32. </android.support.constraint.ConstraintLayout>  

 

 

 

Android

Step 7

Create new calendar_layout.xml file (File ⇒ New ⇒Activity⇒Empty_activity).

Go to calendar_layout.xml then click the text bottom. This xml file contains the designing code for android app. Into the calendar_layout.xml copy and paste the below code

calendar_layout.xml code

 

 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical" android:layout_width="match_parent"  
  4.     android:layout_height="match_parent">  
  5.   
  6.     <CalendarView  
  7.         android:id="@+id/calendarView"  
  8.         android:layout_width="match_parent"  
  9.         android:layout_height="wrap_content" />  
  10. </LinearLayout>  

 

Android

Step 8

Into the MainActivity.java copy and paste the below code.java programming is the backend language for android. Do not replace your package name otherwise app will not run.

MainActivity.java code

 
  1. package ganeshannt.calendarview;  
  2.   
  3. import android.content.Intent;  
  4. import android.os.Bundle;  
  5. import android.support.v7.app.AppCompatActivity;  
  6. import android.view.View;  
  7. import android.widget.Button;  
  8. import android.widget.TextView;  
  9.   
  10. public class MainActivity extends AppCompatActivity {  
  11.   
  12.     private static final String TAG = "MainActivity";  
  13.   
  14.     private TextView thedate;  
  15.     private Button btngocalendar;  
  16.   
  17.     @Override  
  18.     protected void onCreate(Bundle savedInstanceState) {  
  19.         super.onCreate(savedInstanceState);  
  20.         setContentView(R.layout.activity_main);  
  21.         thedate = (TextView) findViewById(R.id.date);  
  22.         btngocalendar = (Button) findViewById(R.id.btngocalendar);  
  23.   
  24.         Intent incoming = getIntent();  
  25.         String date = incoming.getStringExtra("date");  
  26.         thedate.setText(date);  
  27.   
  28.         btngocalendar.setOnClickListener(new View.OnClickListener() {  
  29.             @Override  
  30.             public void onClick(View v) {  
  31.                 Intent intent = new Intent(MainActivity.this,CalendarActivity.class);  
  32.                 startActivity(intent);  
  33.             }  
  34.         });  
  35.     }  
  36. }  

 

 

Step 9

Create new CalendarActivity.java file (File ⇒ New ⇒Java class).

Into the CalendarActivity.java copy and paste the below code.java programming is the backend language for android. Do not replace your package name otherwise app will not run.

CalendarActivity.java code

 
  1. package ganeshannt.calendarview;  
  2.   
  3. import android.content.Intent;  
  4. import android.os.Bundle;  
  5. import android.support.annotation.Nullable;  
  6. import android.support.v7.app.AppCompatActivity;  
  7. import android.util.Log;  
  8. import android.widget.CalendarView;  
  9.   
  10. /** 
  11.  * Created by ganesh on 6/10/2017. 
  12.  */  
  13.   
  14. public class CalendarActivity extends AppCompatActivity {  
  15.   
  16.     private  static final String TAG = "CalendarActivity";  
  17.     private CalendarView mCalendarView;  
  18.     @Override  
  19.     protected void onCreate(@Nullable Bundle savedInstanceState) {  
  20.         super.onCreate(savedInstanceState);  
  21.         setContentView(R.layout.calendar_layout);  
  22.         mCalendarView = (CalendarView) findViewById(R.id.calendarView);  
  23.         mCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {  
  24.             @Override  
  25.             public void onSelectedDayChange(CalendarView CalendarView, int year, int month, int dayOfMonth) {  
  26.               String date = year + "/" + month + "/"+ dayOfMonth ;  
  27.                 Log.d(TAG, "onSelectedDayChange: yyyy/mm/dd:" + date);  
  28.                 Intent intent = new Intent(CalendarActivity.this,MainActivity.class);  
  29.                 intent.putExtra("date",date);  
  30.                 startActivity(intent);  
  31.   
  32.             }  
  33.         });  
  34.     }  
  35. }  

Step 10

Add the calendaractivity into the androidmanifest.xml so add below code into the AndroidManifest.xml.

AndroidManifest.xml code

 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="ganeshannt.calendarview">  
  4.   
  5.     <application  
  6.         android:allowBackup="true"  
  7.         android:icon="@mipmap/ic_launcher"  
  8.         android:label="@string/app_name"  
  9.         android:roundIcon="@mipmap/ic_launcher_round"  
  10.         android:supportsRtl="true"  
  11.         android:theme="@style/AppTheme">  
  12.         <activity android:name=".MainActivity">  
  13.             <intent-filter>  
  14.                 <action android:name="android.intent.action.MAIN" />  
  15.   
  16.                 <category android:name="android.intent.category.LAUNCHER" />  
  17.             </intent-filter>  
  18.         </activity>  
  19.         <activity android:name=".CalendarActivity"></activity>  
  20.     </application>  
  21.   
  22. </manifest>  

Step 11

 

This is our user interface of the application. Click the make project option.

Android

Deliverables

Here calendar view in android application was successfully created and executed.

Android

Android

Android

Android

Android

0 0
ممنون،خیلی لطف کردی،ولی من میخوام توش فعالیت ذخیره کنم و میخوام مثل عکس تقویم سمت چپ باشه (8 سال پیش)

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .