이전 응용 프로그램 활동에서 얻는 데 문제가 있습니다. 내 사례는 ListOfMeals로 알려진 이전 활동입니다. 목록보기 (아침, 아침 간식 등)가 있습니다. 아침 식사를 클릭하고 식사를 추가하면 빵, 과일, 채소 등의 음식 목록을 클릭합니다. 그 후에는 데이터베이스에 추가해야합니다. 하지만 지금까지 내가 가진 것은 이것입니다. 아래를 참조하십시오 :ANDROID가 이전 활동의 데이터를 가져옵니다.
case R.id.btFoodVegetableSave:
String mealname = selected;
String serving = calories.getText().toString();
int i = Integer.parseInt(serving.replaceAll("[\\D]", ""));
String servng = String.valueOf(i);
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
String strDate = sdf.format(new Date());
if ((mealname.isEmpty() || servng.isEmpty())){
// call for custom toast
viewErrorToast();
}
else {
boolean didItWork = true;
try{
BreakFastLog entry = new BreakFastLog(Baguettes_Bagels.this);
entry.open();
entry.createEntry(mealname, servng, strDate);
entry.close();
}
catch(Exception e){
didItWork = false;
viewErrorToast();
}finally{
if (didItWork){
viewBMRSavedToast();
}
}
} // end of if else statement
break;
예를 들어, 내 예제 만 저장합니다. 아침 식사가 아닌 아침 간식을 선택할 때 문제가 발생합니다. 이전 활동에서 사용자가 선택한 것을 어떻게 가져 와서 각각의 식사에 저장할 수 있습니까?
BreakFastLog entry = new BreakFastLog(Baguettes_Bagels.this);
entry.open();
entry.createEntry(mealname, servng, strDate);
entry.close();
것은 내가 다른 if 문을 넣어,하지만 난이 구현하는 일부 영리한 방법을 생각 할 수 없습니다
내가는이 함께 할 수있는 뭔가를 가지고 알고있다. 사전에 도움을 주셔서 감사합니다. 당신은 추가 할 수 있습니다
Intent intent = new Intent(...);
startActivity(intent);
: 당신이 활동을 시작하면