-5

如何在特定点终止函数我使用中断但它不起作用请帮助我当当前日期与数据库匹配时没有进一步处理并且函数关闭中断不起作用没有其他建议吗??????

                public class getDataTask extends AsyncTask<Void, Void, Void> {

    getDataTask() {

    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
         yourBoolean=false;
    }

    @Override
    protected Void doInBackground(Void... arg0) {
        // TODO Auto-generated method stub

        displayData();
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        yourBoolean=true ;
        listCategory.setAdapter(cla);
        menu_nametxt.setText(mVal2);
                                  }








                    private void displayData() {


    Cursor mCursor2 =  db.selectQuery("SELECT s.name ASxxxx ORDER BY md.sort ASC");


    if (mCursor2.moveToFirst()) {
        do {



        Calendar_id =(mCursor2.getString(mCursor2.getColumnIndex("calendar_id")));


        } while (mCursor2.moveToNext());
    }


    mCursor2.close();






 Cursor mCursor3 =  db.selectQuery("SELECT * FROM uss_vacation WHERE calendar_id = 
      '"+Calendar_id+"' ");


    if (mCursor3.moveToFirst()) {
        do {


  Vacation_Date.add(mCursor3.getString(mCursor3.getColumnIndex("date")));

    if(mCursor3.getString(mCursor3.getColumnIndex("date")).equals(mydate))
            {
           String  mVal  ;
                mVal = 
  (mCursor3.getString(mCursor3.getColumnIndex("title")));

        //
                mVal3 = mVal;

  //////////////////////////////help here//////////////////////
 i want function displayData(); close at this like and not processing further any idea?? i used 
    break but is not work
                break;

            }


        } while (mCursor3.moveToNext());
    }


    mCursor3.close();








Cursor mCursor =  db.selectQuery("SELECT s.name  '"+Meal_groupid+"' ORDER BY md.sort ASC");
    Category_ID.clear();
    school_name.clear();
    menu_name.clear();

    dish_name.clear();
    dish_ID.clear();
    day.clear();



    if (mCursor.moveToFirst()) {
        do {

            zero1check = valll.toString();
            if (zero1check.equals("0"))
                byweekdate = Todayday + 1;
            else if (zero1check.equals("1")) {
                byweekdate = Todayday + 2;

            }

      school_name.add(mCursor.getString(mCursor.getColumnIndex("school_name")));
            String Scdedulechk;

            Scdedulechk=(mCursor.getString(mCursor.getColumnIndex("Schedule")));
            Schedule.add(mCursor.getString(mCursor.getColumnIndex("Schedule")));
            day.add(mCursor.getString(mCursor.getColumnIndex("day")));

            String chkdate;

            chkdate=(mCursor.getString(mCursor.getColumnIndex("day")));


            if ((Scdedulechk).equals("weekly")) {

                if ((chkdate).equals(Todayday)) {




       menu_name.add(mCursor.getString(mCursor.getColumnIndex("menu_title")));
            String menu_title;

            menu_title=
      (mCursor.getString(mCursor.getColumnIndex("menu_title")));
            mVal2=menu_title.toString();


   dish_name.add(mCursor.getString(mCursor.getColumnIndex("dish_name")));

dish_ID.add(mCursor.getString(mCursor.getColumnIndex("dish_id")));



   Category_ID.add(mCursor.getString(mCursor.getColumnIndex("calendar_id")));
                }
            }
            else 
                if ((Scdedulechk).equals("biweekly")) {

                    if ((chkdate).equals(byweekdate)) {




   menu_name.add(mCursor.getString(mCursor.getColumnIndex("menu_title")));


   dish_name.add(mCursor.getString(mCursor.getColumnIndex("dish_name")));


     dish_ID.add(mCursor.getString(mCursor.getColumnIndex("dish_id")));



    Category_ID.add(mCursor.getString(mCursor.getColumnIndex("calendar_id")));
                    }
                }


        } while (mCursor.moveToNext());
    }


    mCursor.close();


}
4

2 回答 2

0

替换breakreturnbreak只是打破循环,return“停止”该方法。

于 2013-11-02T08:13:17.490 回答
0

将函数的返回类型从 void 更改为 int 或其他,并在所需操作完成时返回任何内容。例如。

int test_func(){ 

 //your code here
if(actionCompleted){
    return 1;
// function will be closed 
 }
else
//your code

return 0;
}  
于 2013-11-02T10:41:37.137 回答