这是我的回收视图中聊天窗口的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_weight="418"
android:layout_width="0dp"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="100"
android:gravity="right"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/btn_profilepic_recview_chats"
android:background="@drawable/ripple"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="323"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="100"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="323"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/chat_img_bubbletop"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 这是一个非常苛刻的问题,只是我很长时间没有这样做,需要一些帮助.
所以这就是问题所在.我在我的列表"lstfriendlist"上有这个调试信息:

我只是在我的活动中设置一个断点,然后点击我的列表,看到我所有的"朋友"都在"friendUsername"下的这个列表中被带到我这里.
我能够通过以下方式检索某个用户名:
string temp = lstfriendList[11].friendUsername.ToString();
Run Code Online (Sandbox Code Playgroud)
这会在我的字符串"temp"上返回"torben".
现在我忘了如何使用foreach循环从列表中按顺序检索所有对象,然后将它们写下来.我很抱歉打扰你,但我忘记了:(
我希望你能帮助我.谢谢 :)