2015-09-05 119 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)的 –