Ids aus einer Tabelle und das Abgleichen mit einer anderen Tabelle und Datensatz aus dieser Tabelle.Einmal bekomme ich Datensätze in Liste, aber wenn ich einen weiteren Datensatz in Liste illegalexception einfügen möchte das ist nicht usw.Abrufen von Datensatz aus der lokalen Datenbank und Anzeigen in Listview IllegalStateException:
private void getAllRecords() {
String cmpId = "";
//fetching ids from this table one by one and passing id to another table
Cursor preAppointmentRecord = JasperDatabase.getInstance(PreAppointmentsActivity.this).getPreAppointmentRecord();
preAppointmentRecord.moveToFirst();
if (preAppointmentRecord.getCount() != 0) {
while (!preAppointmentRecord.isAfterLast()) {
cmpId = preAppointmentRecord.getString(1);
getAllCompanyName(cmpId);
preAppointmentRecord.moveToNext();
}
preAppointmentRecord.close();
}
}
private void getAllCompanyName(String companyId) {
//fetching company names with matched ids
Cursor companyNameCursor = JasperDatabase.getInstance(PreAppointmentsActivity.this).getPreAppointmentCompanies(companyId);
companyNameCursor.moveToFirst();
if (companyNameCursor.getCount() != 0) {
while (!companyNameCursor.isAfterLast()) {
//getting second string from database
recordsAr.add(new PreAppointmentRecord(companyNameCursor.getString(2)));
companyNameCursor.moveToNext();
}
companyNameCursor.close();
}
}
AsyncTask Klasse getAllRecords für den Aufruf zur Listenansicht gemeldet() Funktion:
protected Void doInBackground(String[] paramArrayOfString) {
getAllRecords();
return null;
}
protected void onPostExecute(Void paramVoid) {
super.onPostExecute(paramVoid);
if (mProgressDialog.isShowing())
mProgressDialog.dismiss();
//Notifying to listview for changing view
customRecordsAdapter.notifyDataSetChanged();
}
Kundenadapter:
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
final int k = 0 ;
//Using for getting all record storing in recordArray
final PreAppointmentRecord preRecord = recordsAr.get(i);
Logcat:
FATAL EXCEPTION: main Process: com.jmd.jasper, PID: 11265
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131558625, class android.widget.ListView) with Adapter(class com.jmd.jasper.activities.PreAppointmentsActivity$CustomRecordsAdapter)]
at android.widget.ListView.layoutChildren(ListView.java:1566)
at android.widget.AbsListView.onLayout(AbsListView.java:2564)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:493)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15601)
at android.view.ViewGroup.layout(ViewGroup.java:4881)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
Kunden Adapter:
private class CustomRecordsAdapter extends BaseAdapter {
@Override
public int getCount() {
return recordsAr.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
final int k = 0 ;
final PreAppointmentRecord preRecord = recordsAr.get(i);
// final PreAppointmentCustomer1 preRecord1 = recordsAr1.get(k);
view = View.inflate(PreAppointmentsActivity.this, R.layout.custom_record_list_preappointment, null);
TextView companyNameTextView = (TextView) view.findViewById(R.id.companyNameTextView);
companyNameTextView.setText(preRecord.CompanyName);
// nameTextView.setText(preRecord1.CustomerId);
return view;
}
}
hinzufügen Informationen melden Sie sich zu finden, was eigentlich falsch – USKMobility
werde ich die logcat hinzugefügt haben unter –
fügen Sie Ihre Aktivität und benutzerdefinierte Adapter vollständige Code – USKMobility