CalendarView在垂直向上滚动时崩溃

时间:2013-11-17 23:50:54

标签: android

这是情况。我创建了一个仅显示一周的CalendarView。向下滚动浏览CalendarView时,应用程序运行正常。但是,在尝试垂直向上滚动时,应用程序崩溃。

这是我的代码:

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="match_parent"
android:orientation="vertical" 
android:gravity="center_horizontal">



<CalendarView
    android:id="@id/businesscalendarView"
    android:layout_width="match_parent"
    android:layout_height="138dp" 
    android:shownWeekCount="1"/>

<ListView
    android:id="@+id/ListOfHoursForBusiness"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fadeScrollbars="false"
    android:scrollbars="vertical" />

</LinearLayout>

这是java:

public class businessCalendar extends Activity implements OnDateChangeListener, OnItemClickListener {

private ArrayAdapter<String> adapter;
private ArrayList<String> listItems = new ArrayList<String>();
String[] listTimes = new String[] { "8am", "9am", "10am",
        "11am", "12pm", "1pm", "2pm", "3pm",
        "4pm", "5pm", "6pm", "7pm", "8pm" };

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);



    setContentView(R.layout.businesscalendar);

    CalendarView cal = (CalendarView) findViewById(R.id.businesscalendarView);
    cal.setOnDateChangeListener(this);





    ListView listView = (ListView)this.findViewById(R.id.ListOfHoursForBusiness);
    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, listTimes);        
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
}

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub

}

@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
        int dayOfMonth) {
    // TODO Auto-generated method stub

}

}

有什么想法吗?看着它和其他日历我看不出有什么不同,只是我发送的周数是1。

0 个答案:

没有答案