-1
以下代碼在listview中顯示來自sqlite數據庫的信息。它顯示日期和列表視圖允許我點擊,當我點擊一個日期時,它顯示我在該日期在列表視圖上完成的信息。我的問題是,當我在這個日期保存數據12.01.2013和我重複同一日期後,然後它顯示相同的日期兩次,我想它只是顯示一個日期,當我點擊它來顯示我的數據,我在早上保存,並且我在同一天晚些時候保存的數據不是兩個相似的日期。將數據顯示到列表視圖中
hereis代碼
public class Pro extends Activity implements OnItemClickListener {
private ListView uNamesListView;
private ListAdapter customerListAdapter;
private ArrayList<PojoClass> pojoArrayList;
final Context context = this;
private Button button;
private TextView result;
DBAdapter db = new DBAdapter(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
uNamesListView = (ListView) findViewById(R.id.listView1);
uNamesListView.setOnItemClickListener(this);
pojoArrayList = new ArrayList<PojoClass>();
customerListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
uNamesListView.setAdapter(customerListAdapter);
}
public List<String> populateList() {
List<String> uGraduateNamesList = new ArrayList<String>();
DatabaseHelper openHelperClass = new DatabaseHelper(this);
SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
Cursor cursor = sqliteDatabase.query(DBAdapter.SCAN_TABLE, null, null, null, null, null, null);
startManagingCursor(cursor);
while (cursor.moveToNext()) {
String cDate = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_Date));
String cMeterNumber = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_MeterNumber));
String cVname = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_Vname));
String cPname = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_PName));
PojoClass ss = new PojoClass();
ss.SetName(cDate);
ss.SetSurname(cMeterNumber);
ss.SetID(cVname);
ss.SetHaddress(cPname);
pojoArrayList.add(ss);
uGraduateNamesList.add(cDate);
}
sqliteDatabase.close();
return uGraduateNamesList;
}
@Override
public void onItemClick(AdapterView<?> aa, View view, int ss, long bb) {
// TODO Auto-generated method stub
Intent updateCustomerIntent = new Intent(Pro.this, ViewByVendor.class);
updateCustomerIntent.putExtra("product", product);
startActivity(updateCustomerIntent);
Toast.makeText(getApplicationContext(), "Clicked on :" + ss, Toast.LENGTH_SHORT).show();
PojoClass clickedObject = pojoArrayList.get(ss);
Bundle dataBundle = new Bundle();
dataBundle.putString("clickedDate", clickedObject.getDates());
dataBundle.putString("clickedMeterNumber", clickedObject.getMeterNumber());
dataBundle.putString("clickedVname", clickedObject.getVname());
dataBundle.putString("clickedPname", clickedObject.getPname());
updateCustomerIntent.putExtras(dataBundle);
startActivity(updateCustomerIntent);
}
}
我會感謝你的幫助。