2015-09-05 63 views
0
public void startAttendance(View view) 
{ 
    Spinner sp=(Spinner) findViewById(R.id.tablepass); 
    tbl_nm=sp.getSelectedItem().toString(); 
    if(checkForEntries()!=0) { 
     Cursor c = db.rawQuery("select * from "+ tbl_nm, null); 
      if(c!=null) { 
       if (c.moveToFirst()) 
       do { 

        String n1 = c.getString(c.getColumnIndex("Name")); 
        String n2 = c.getString(c.getColumnIndex("Branch")); 
        Intent i = new Intent(this, Attendance.class); 
        Bundle b = new Bundle(); 
        b.putString("n1", n1); 
        b.putString("n2", n2); 
        b.get("n1"); 
        b.get("n2"); 
        i.putExtras(b); 
        startActivity(i); 
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); 
        String attendance = sharedPref.getString("attendance", "default"); 
        ContentValues cv = new ContentValues(); 
        cv.put("attendance", attendance); 
        db.insertOrThrow(tbl_nm, null, cv); 
        Toast.makeText(this, "Entered", Toast.LENGTH_SHORT).show(); 
       }while(c.moveToNext()); 
       } 
       } 

} 

****出席活動****如何使呼叫活動(prepopup)等待完成被叫活動(出席)任務?

public class Attendance extends ActionBarActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_attendance); 
    Intent i=getIntent(); 
    Bundle b=i.getExtras(); 
    String name=b.getString("n1"); 
    String branch=b.getString("n2"); 
    TextView tv5=(TextView) findViewById(R.id.textView5); 
    TextView tv6=(TextView) findViewById(R.id.textView6); 
    tv5.setText(name); 
    tv6.setText(branch); 
} 

public void check(View v) 
{ 
    SharedPreferences sharedPref; 
    SharedPreferences.Editor editor; 
    switch (v.getId()) 
    { 

     case R.id.button6: 
      sharedPref = PreferenceManager.getDefaultSharedPreferences(this); 
      editor = sharedPref.edit(); 
      editor.putString("attendance","present"); 
      editor.commit(); 
      break; 
     case R.id.button7: 
      sharedPref = PreferenceManager.getDefaultSharedPreferences(this); 
      editor = sharedPref.edit(); 
      editor.putString("attendance","absent"); 
      editor.commit(); 
      break; 


    } 
    finish(); 
    } 
} 
+0

prepopup被反覆呼籲出席活動並不止一次。信息的 –

回答

0

我猜你使用的是錯誤的做法在這裏,您是從本地數據庫中獲取數據,併爲每個記錄您呼叫其他活動。這就是出席活動的多個實例正在創建的原因。

您應該首先獲取所有記錄並將其存儲在數組列表中,使用此數組列表中的數據顯示一個微調框,並在選擇微調框中的項目時,導航至出席活動。 理想情況下,這應該是方法,因爲假設有200條記錄,請想象一下將創建多少個活動考勤實例, 第二件事,如果這些許多記錄必須被操縱並且兩個活動相互依賴,我不會認爲用戶每次點擊一個按鈕時將等待200條記錄彈出。

讓我知道它是否適合你和你的想法, 將其標記爲一個答案這樣,這將是有用的人......

+0

thanx。我會試一試。 (y)的 –