日历查看膳食计划

时间:2016-02-15 19:07:04

标签: java android calendar calendarview

我正在尝试创建一个烹饪应用程序

任何人都可以帮我尝试创建一个日历视图,点击一天,然后出现一个包含早餐午餐和晚餐的新对话框,然后点击早餐晚餐或午餐,然后你就会被带到一个新的你输入食物的页面(我有一个用食物设置的sqlite数据库)

我设置了日历视图

<RelativeLayout 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=".Calendar_View"
android:id="@+id/calendar_view">

<CalendarView
    android:id="@+id/calendarView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="20dp" />

</RelativeLayout>

calendar_view.java

public class Calendar_View extends Activity {

CalendarView cal;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.calendar_view);

    cal = (CalendarView) findViewById(R.id.calendarView1);

    cal.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

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

            Toast.makeText(getBaseContext(), "Selected Date is\n\n"
                            + dayOfMonth + " : " + month + " : " + year,
                    Toast.LENGTH_LONG).show();
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.calendar_view, menu);
    return true;
}
}

但是当我点击主页上的链接时,它就不会出现

public class Home_Screen extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_screen);
}

public void onClick(View v) {
    //click on search by recipe
    if (v.getId() == R.id.search_recipes) {
        startActivity(new Intent(getApplicationContext(), MainActivity.class));
    }

    //click on search by ingredients
    if (v.getId() == R.id.search_by_ingredients) {
        startActivity(new Intent(getApplicationContext(), Search_By_Ingredients.class));
    }

    //click on meal planner
    if (v.getId() == R.id.calendar_view) {
        startActivity(new Intent(getApplicationContext(), Calendar_View.class));
    }

    //click on food allergies
    if (v.getId() == R.id.food_allergies) {
        startActivity(new Intent(getApplicationContext(), Food_Allergies.class));
    }

}

}

有没有人对如何解决这个问题有任何想法,以及如何像我上面建议的那样制作膳食计划员

0 个答案:

没有答案