Я пытаюсь сделать просмотр списка с изображениями и текстом рядом для каждого пользователя, кроме текущего пользователя (то есть пользователя устройства).
У меня есть структура JSON, подобная следующей:
|
--- users
|
|
--- uid1
| |
| -- uid1
| |
| -- name
| |
| -- imageURL
| |
-- status
|
-- email
|
-- line
|
|
--- uid2
Это мой класс адаптера:
public class MyAdapter extends ArrayAdapter<OtherUsers> {
private Activity context;
private int resource;
private List<OtherUsers> list;
public DayAdapter(@NonNull Activity context, int resource, List<OtherUsers> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.list = objects;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// I am not able to figure out this part
}
}
Класс OtherUsers
public class OtherUsers {
private String line;
private String imageURL;
public OtherUsers(String line, String imageURL){
this.line = line;
this.imageURL = imageURL;
}
public OtherUsers(){
}
public String getLine(){
return line;
}
public String getImageURL(){
return imageURL;
}
public void setLinee(String line){
this.line = line;
}
public void setImageURL(String imageURL){
this.imageURL = imageURL;
}
}
В моем представлении списка есть код XML, подобный следующему:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back2"
android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="80dp"
android:id="@+id/image"
android:layout_height="80dp"
android:layout_weight="0.11"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dlne"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image"
android:textColor="#333"
android:textSize="22sp"
android:textStyle="bold"/>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/button1"
android:elevation="10dp"
app:fabSize="normal"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/profile"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Я не застрял в получении данных.Я могу получить данные из Firebase, я не могу понять, как я могу заполнить представление списка изображениями и строками.
Буду признателен, если кто-нибудь сможет мне помочь в этом.