小编Mar*_*nto的帖子

替代聊天气泡宽度

我正在开发一个聊天类型的应用程序 我正在使用两个不同的九个补丁来聊天泡泡主要消息和响应.我面临的问题是根据消息长度自动包装气泡的宽度.以下是我的主要布局:

<RelativeLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    >

 <ListView android:id="@+id/list"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:stackFromBottom="true"
    android:transcriptMode="alwaysScroll"
    android:cacheColorHint="#00000000"
    android:listSelector="@android:color/transparent"
    android:divider="@null"
    />
 </RelativeLayout>

<LinearLayout android:id="@+id/footer" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:orientation="horizontal"
    android:gravity="bottom" style="@android:style/ButtonBar">
    <Button
        android:id="@+id/stt_button"
        android:layout_width="45dp"
        android:layout_height="50dp"
        android:background="@drawable/microphone"
    />   

    <EditText android:id="@+id/chat_msg"
        android:inputType="text" 
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_weight="1" />

    <Button android:id="@+id/send_button"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_gravity="center_vertical"
        android:text="@string/send_button" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的list_item布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content" android:weightSum="1.0"
android:layout_weight="1" android:layout_height="wrap_content">
<LinearLayout         
    android:id="@+id/linearLayoutLeft" 
    android:layout_width="0dp"
    android:layout_weight="0.8"
    android:layout_height="wrap_content">
    <RelativeLayout 
        android:id="@+id/relativeLayoutLeft" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/lefttext" 
            android:layout_width="wrap_content" 
            android:gravity="top" 
            android:layout_height="wrap_content" 
            android:paddingLeft="10dip" 
            android:paddingRight="10dip" 
            android:paddingTop="5dip" 
            android:layout_alignParentLeft="true">
        </TextView>
    </RelativeLayout>
</LinearLayout>
<LinearLayout         
    android:id="@+id/linearLayoutRight"
    android:layout_width="0dp" …
Run Code Online (Sandbox Code Playgroud)

android android-layout

3
推荐指数
1
解决办法
7553
查看次数

收到致命警报:handshake_failure

我正在尝试使用liferay中的javapns库向我的设备发送推送通知.这是代码:

private void pushNotification(ActionRequest actionRequest,
            ActionResponse actionResponse) {

        try {
            System.out.println("Push");

            Push.alert("Hello World!", "ck.p12", "PASSPHRASE", false, "TOKEN");

        } catch (CommunicationException e) {
            System.out.println("CommunicationException");
            e.printStackTrace();
        } catch (KeystoreException e) {
            System.out.println("KeystoreException");
            e.printStackTrace();
        }

    }
Run Code Online (Sandbox Code Playgroud)

调用pushNotification时出现此错误:

ERROR [PushNotificationManager:450] Delivery error: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索但找不到任何解决方案.

有谁知道如何解决这个问题?

java liferay push-notification

3
推荐指数
1
解决办法
2万
查看次数

算法 - java,c#或delphi - 搜索存在多于arraySize/2的数组中的数字.一次传递没有额外的内存

我需要做一个搜索int数组中特定int的算法.该数字必须> = arraySize/2次.

例如:[] = 4 4 3 5 5 5 5 5 5 6 arraysize:10 number 5存在6x - >所以这是算法的结果

但是我需要在没有额外内存的情况下这样做,并且在一次通过中及时O(n) - >.

这甚至可能吗?有什么建议怎么开始吗?

c# java algorithm

2
推荐指数
1
解决办法
1357
查看次数

更改应用背景

我正在制作一个Android应用程序,我希望用户能够更改背景图像.我有3个图像和一个屏幕,我可以选择一个图片和一个按钮进行申请.

问题: 我可以让用户以我想要的方式查看所有图像,但我不知道如何将所选图像设置为应用程序背景.

我想做的是: 我希望用户单击一个按钮,将所选图像导出到"/ res/drawable-mdpi"中的"bakgrund.png"并替换当前图像.这样我就可以轻松集成背景切换器.重命名当前文件也有效.

PS:我当前的背景图片位于/ res/drawable-mdpi,名为1.png 2.png和3.png.

java settings android background

2
推荐指数
1
解决办法
424
查看次数

Android在Google地图API中获取公共交通?

我知道有可用的json格式api用于公共交通而不是驾驶吗?

android google-maps google-maps-api-3 gtfs

1
推荐指数
1
解决办法
1253
查看次数

谷歌应用引擎get_serving_url()未定义

这似乎是一个简单的问题,但我无法弄清楚:

get_serving_url()在我的代码中调用函数并得到错误:

NameError:未定义全局名称"get_serving_url"

我的import语句目前看起来像是:来自google.appengine.api导入图片

之前我尝试了各种"从PIL导入图像"并导致导入错误.我最近安装了PIL库

我的python路径上有site-packages和PIL文件夹

我该如何get_serving_url()工作?

python import google-app-engine python-imaging-library

1
推荐指数
1
解决办法
701
查看次数

Clickable LinearLayout在点击时不闪烁

在我的Android应用中,我有一个包含其他视图的LinearLayout视图.LinearLayout是可点击的,但是当它被点击时,它不会像它应该那样闪烁橙色.

怎么才能让它闪存?

android

0
推荐指数
1
解决办法
4739
查看次数

ProgressDialog使用AsyncTask生成构造函数未定义错误

public class async extends AsyncTask<String, Integer, String>{
ProgressDialog prog;
@Override
protected void onPreExecute() {

    super.onPreExecute();
    prog=new ProgressDialog(async.this);//This is chowing error 
    prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    prog.setMax(100);
    prog.show();

}

    @Override
    protected String doInBackground(String... params) {
        for (int i = 0; i < 10; i++) {
        publishProgress(5);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }

@Override
protected void onPostExecute(String result) {

    super.onPostExecute(result);
    prog.dismiss();
}
@Override
protected void onProgressUpdate(Integer... values) {
    prog.setProgress(values[0]);
    super.onProgressUpdate(values);
}
}
Run Code Online (Sandbox Code Playgroud)

上面的代码产生错误: …

android progressdialog android-asynctask

0
推荐指数
1
解决办法
3376
查看次数