Я создаю контактную заявку в android студии. все остальные вещи, такие как вход в систему, регистрация работают в приложении. Я не получаю свои данные из базы данных без базы данных в списке просмотра android studio. но моя активность работает, и к сбоям есть в приложении. кто-нибудь может помочь?
view_contacts. java
package com.example.testapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.backendless.Backendless;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessFault;
import com.backendless.persistence.DataQueryBuilder;
import java.util.List;
public class view_contact extends AppCompatActivity {
ListView lvlist;
ContactAdapter adapter;
TextView contacts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_contact);
contacts=findViewById(R.id.tvcontacts);
lvlist=findViewById(R.id.list_view);
String whereClause="userEmail = '" + TestApplication.user.getEmail() +"'";
DataQueryBuilder queryBuilder=DataQueryBuilder.create();
queryBuilder.setWhereClause(whereClause);
queryBuilder.setGroupBy("name");
Backendless.Persistence.of(Contact.class).find(queryBuilder, new AsyncCallback<List<Contact>>() {
@Override
public void handleResponse(List<Contact> response) {
TestApplication.contacts = response;
adapter=new ContactAdapter(view_contact.this,TestApplication.contacts);
lvlist.setAdapter(adapter);
}
@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(view_contact.this, "Error : "+fault.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
ContactsAdapter. java
package com.example.testapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.List;
public class ContactAdapter extends ArrayAdapter<Contact> {
private Context context;
private List<Contact> contacts;
public ContactAdapter(@NonNull Context context, List<Contact> contacts) {
super(context,R.layout.row_layout);
this.context = context;
this.contacts = contacts;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView= inflater.inflate(R.layout.row_layout,parent,false);
TextView tvchar=convertView.findViewById(R.id.tvchar);
TextView tvname=convertView.findViewById(R.id.tvname);
TextView tvmail=convertView.findViewById(R.id.tvmail);
tvchar.setText(contacts.get(position).getName().toUpperCase().charAt(0));
tvname.setText(contacts.get(position).getName());
tvmail.setText(contacts.get(position).getEmail());
return convertView;
}
}
TestApplication. java
// I have set up my backendless database code above and my list is declared public below
public static List<Contact> contacts;
logcat: -
2020-02-12 18:27:55.078 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)
2020-02-12 18:27:58.118 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)
2020-02-12 18:27:58.138 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)
2020-02-12 18:27:58.152 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)
2020-02-12 18:27:58.170 13205-13229/com.example.testapp I/chatty: uid=10090(com.example.testapp) RenderThread identical 1 line
2020-02-12 18:27:58.178 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)
2020-02-12 18:27:59.649 13205-13229/com.example.testapp D/EGL_emulation: eglMakeCurrent: 0xa1107260: ver 2 0 (tinfo 0xa901b4f0)