我正在Android上编写聊天客户端,但是我在客户端放置聊天气泡时遇到了一些问题.我的聊天屏幕包含ListView一个文本框和一个底部的发送按钮.对于传出消息,文本ListView在行中保持对齐.对于传入消息,文本ListView在行中右对齐.但是,聊天气泡不会调整为传入消息文本的长度.左对齐的传出消息不会发生此问题.
屏幕截图如下.
图片http://i40.tinypic.com/5fgen6.png
聊天消息文本存储在数据库中,并ListView通过游标适配器显示.聊天文本的对齐是在Java源代码中即时确定的MessageAdapter.两个聊天气泡都是使用Android的九个补丁图片完成的.
下面是我的聊天活动布局,ListView问题是messageHistoryList:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/messageHistoryList"
android:layout_width="wrap_content"
android:layout_height="0px"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:layout_weight="1"/>
<Button
android:id="@+id/sendMessageButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="Send"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
ListView行布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/userAndMessage">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textUser"
android:textStyle="bold"
android:textColor="@color/blue"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textMessage"
android:textColor="@color/blue"
android:textStyle="bold"/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我正在使用 NLog 登录我的库,并且创建了自定义 NLog 目标以将日志条目上传到 Azure 数据资源管理器。但是,如果将日志上传到 Azure 数据资源管理器时遇到异常,我想在本地日志文件中记录错误消息。
但是,我无法使用 NLog 的文件目标来记录此错误,因为再次调用 NLog 的日志记录 API 时,我的自定义目标将再次被调用,从而导致无限循环。
因此,我想使用NLog的InternalLogger,它记录到NLog的内部日志文件中,来记录上传错误。但是,当我使用下面的 InternalLogger 方法时,它不会记录到内部日志文件。
InternalLogger.Error(e, msg);
Run Code Online (Sandbox Code Playgroud)
InternalLogger 类记录在此处
我想知道是否缺少配置步骤或者无法记录到 NLog 的内部日志文件?