What Iam trying to do is to have a list of contacts a user can choose from to start a conversation. That contact would have contactee's profile image and username, and would be clickable (opens MessageActivity)
Can someone help me make since of this?
It's telling me:
Caused by: android.view.InflateException: Binary XML file line #18: addView(View) is not supported in AdapterView
Caused by: java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView
Line 18 is:
<include
layout="@layout/mylist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"/>
which is nested inside a ListView. mylist.xml is a linearlayout.
ContactsActivity
usersRef.child(friendKey).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot friendSnapshot) {
ArrayList<String> ids = new ArrayList<String>();
//String friendName = friendSnapshot.child("username").getValue(String.class);
String friendPicture = friendSnapshot.child("image_url").getValue(String.class);
ImageView friend_icon = findViewById(R.id.friend_icon2);
for (DataSnapshot childSnapshot: friendSnapshot.child("username").getChildren()) {
ids.add(childSnapshot.getValue().toString());
Picasso.get().load(friendPicture).placeholder(R.drawable.placeholder_image).resize(96, 96)
.centerCrop().into(friend_icon);
dataAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.mylist, R.id.Itemname, ids);
lstView = (ListView) findViewById(R.id.contactlist);
lstView.setAdapter(dataAdapter);
individual_contact.setClickable(true);
individual_contact.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//
Intent intent = new Intent(v.getContext(), MessageActivity.class);
ContextCompat.startForegroundService(v.getContext(), intent );
}
});
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException();
}
});