0

我正在開發某些日期顯示事件的日曆的特定類型,並且還顯示日曆下方的相關月份的事件列表。爲此,我受益於Caldroid。這裏是主要的XML文件:如果其他對象在其下方動態膨脹,則不會顯示Android viewpager

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context="com.vbs.android.caltest.MainActivity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fadingEdgeLength="0dp" 
    android:fillViewport="true" 
    android:overScrollMode="never" 
    android:orientation="vertical"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="2" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:id="@+id/calendar1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical"/> 



    <LinearLayout 
     android:id="@+id/eventsList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical"/> 
</LinearLayout> 
</ScrollView> 

進入calendar1 Caldroid安排。這裏是Caldroid xml文件:

<?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="wrap_content" 
style="?styleCaldroidViewLayout" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/calendar_title_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <Button 
     android:id="@+id/calendar_left_arrow" 
     style="?styleCaldroidLeftArrow" /> 

    <TextView 
     android:id="@+id/calendar_month_year_textview" 
     style="?styleCaldroidMonthName"/> 

    <Button 
     android:id="@+id/calendar_right_arrow" 
     style="?styleCaldroidRightArrow" /> 
    </LinearLayout> 

    <GridView 
    android:id="@+id/weekday_gridview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="-10dp" 
    android:numColumns="7" 
    android:stretchMode="columnWidth" > 
    </GridView> 

    <com.antonyt.infiniteviewpager.InfiniteViewPager 
    android:id="@+id/months_infinite_pager" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent"/> 




</LinearLayout> 

所以,Caldroid應用的截圖: enter image description here

的問題是,當我嘗試誇大事件到eventsList(LinearLayout中)日曆的viewpager部分不顯示。我使用以下方法將3個textViews充氣到eventsList中:

public void eventListFiller(){ 
    eventInflater = 
    (LayoutInflater)this.getSystemService(this.LAYOUT_INFLATER_SERVICE); 
    eventsContainer = (LinearLayout) findViewById(R.id.eventsList); 
    View eventContent; 

    for (int i=0; i<array.length; i++){ 
     eventContent = eventInflater.inflate(R.layout.event_list, null); 
     TextView startDateTextView = 
     (TextView) eventContent.findViewById(R.id.startDateTextView); 
     TextView endDateTextView = 
    (TextView) eventContent.findViewById(R.id.endDateTextView); 
     TextView eventTitle =(TextView)eventContent. 
     findViewById(R.id.titleTextView); 
     startDateTextView.setText("startDate"); 
     endDateTextView.setText("endDate"); 
     eventTitle.setText(array[i]); 
     eventsContainer.addView(eventContent); 
    } 

    Log.d("Runned", "EventsListFilled"); 
} 

幫助我解決問題。先謝謝你。

+0

非常感謝Bence,我通過Mielet的(https://github.com/mielet)方法解決了這個問題。 –

回答

0

考慮到更靈活的庫DureyCalendarView。它不使用片段,您可以隨時放置自定義視圖,並且可以輕鬆定義您的XML佈局。

+0

非常感謝Bence,我通過Mielet的(github.com/mielet)方法解決了這個問題 –

相關問題