小编tob*_*ias的帖子

检查JSONArray的具体值

在我的Android Activity中,我通过HTTP包含用户名来获取JSONArray.Array看起来像这样:

[{"username":"Julia"},{"username":"Anja"},{"username":"Hans"},{"username":"Sophia"},{"username":"Sarah"}]
Run Code Online (Sandbox Code Playgroud)

如果给定的用户名已存在,我想检查Android Activity.

最有效的方法是什么?或者我必须迭代整个数组?

android json

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

使用退格键删除整个Spannable

我有一个聊天应用程序,可以在文本中添加表情符号.

我有这个EditText领域的问题.表情符号图像显示但如果我按下普通键盘上的退格按钮,我正在更改为表情符号图片的文本显示,我必须删除几个字符,直到图片消失.我正在使用Spannable这个.

如果用户按下一次退格键,我希望整个笑脸消失.

这里是我使用的代码:

// This is in the keyclicked listener
{
    ...
    smilie = "(angel)";
    break;
    ...
    int cursorPosition = content.getSelectionStart();
    content.getText().insert(cursorPosition, getSmiledText(this, smilie));
    content.getText().insert(cursorPosition + smilie.length(), " ");
}

public static boolean addSmiles(Context context, Spannable spannable) {
    boolean hasChanges = false;
    for (Entry<Pattern, Integer> entry : smilies.entrySet()) {
        Matcher matcher = entry.getKey().matcher(spannable);
        while (matcher.find()) {
            boolean set = true;
            for (ImageSpan span : spannable.getSpans(matcher.start(),
                    matcher.end(), ImageSpan.class))
                if (spannable.getSpanStart(span) >= matcher.start()
                        && spannable.getSpanEnd(span) <= matcher.end()) …
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard android-edittext

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

Android:覆盖透明的图片(jpg)

我有一张想要在屏幕上显示的图片(jpg).此外,图片应部分由透明效果覆盖.透明的封面应该是动态的.因此,例如每天都会显示更多的图片.这张图片展示了我的意思: 在此输入图像描述

我有没有灰色封面的图片,并希望添加此封面,但步骤不同.

有人可以给我一个提示如何做到这一点.

transparency android image

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

md5与Android和PHP

我使用md5来保护我的帖子到运行PHP的后端服务器.参数通过HTTP Post发送.

我有一个问题,我的md5计算结果在Android和PHP服务器上是不同的,如果其中一个输入参数中有ü,ä或ö.

在Android上,哈希是通过此函数计算的:

public static final String md5(final String s) {
    try {
        // Create MD5 Hash
        MessageDigest digest = java.security.MessageDigest
                .getInstance("MD5");
        digest.update(s.getBytes());
        byte messageDigest[] = digest.digest();

        // Create Hex String
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < messageDigest.length; i++) {
            String h = Integer.toHexString(0xFF & messageDigest[i]);
            while (h.length() < 2)
                h = "0" + h;
            hexString.append(h);
        }
        return hexString.toString();

    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return "";
}
Run Code Online (Sandbox Code Playgroud)

在我只是使用的PHP服务器上

md5() function.
Run Code Online (Sandbox Code Playgroud)

php android md5 diacritics

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

Whatsapp和电报的表情符号

我搜索我的Android应用程序的表情符号/表情符号.我发现有一些像pidgin一样可用的开源集.

但我想知道Whatsapp中使用的表情符号.他们基本上非常好.因此我认为他们是由whatsapp许可的.现在我已经安装了消息"电报",我感到很惊讶.他们使用与whatsapp相同的表情符号.这怎么可行?表情符号是否公开?

android emoticons whatsapp

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

HTTP Post将€转换为?符号

我的Android应用程序通过HTTP Post与PHP服务器进行通信.我在以下参数中添加了HTTP请求:

   nameValuePairs.add(new BasicNameValuePair("text", message));
Run Code Online (Sandbox Code Playgroud)

message是一个String,包含符号€

在服务器上,PHP正在运行并获取请求.不幸的是,€符号会自动转换为?符号.所有其他符号的工作方式类似于"ä,ü,$,ß

在Android上我没有设置编码:

  HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://server.com/test.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost); 
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
Run Code Online (Sandbox Code Playgroud)

在PHP网站上我也没有指定任何内容.这里的代码:

<?php

mysql_connect("blablaost.com", "blabla", "blabla") or die(mysql_error());
mysql_select_db("asfd") or die(mysql_error());
$mysqldate = gmdate( 'Y-m-d H:i:s');

$language = (int) $_REQUEST['language'];

mysql_query("blabla ... .$_REQUEST['text']. ") 
or die(mysql_error());  

mysql_close();

?>
Run Code Online (Sandbox Code Playgroud)

$ _REQUEST ['text']包含€,它给了我一个?

php android http

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

夹板:解析 for 循环中的错误

我使用夹板作为 c99 代码的静态分析器。

夹板似乎不太符合 c99。因此我应用了这个补丁:http : //www.cs.virginia.edu/pipermail/splint-discuss/attachments/20080718/52cc25f6/attachment.obj

现在,由于声明不在顶部,我没有得到解析错误

但是如果我在 for 语句中放入一个变量声明,我仍然会在 for 循环中遇到解析错误。例如:

for(int i = 0; i < 10; i++)
{
}
Run Code Online (Sandbox Code Playgroud)

一种解决方法是这样写:

int i;
    for(i = 0; i < 10; i++){
    }
Run Code Online (Sandbox Code Playgroud)

但是因为我不想适应我所有的 for 循环,我想知道是否有可用的补丁来解决这个问题。

c static-analysis splint

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

如何获得片段的rootview?

我正在使用此库在我的应用程序上使用表情符号键盘。 https://github.com/ankushsachdeva/emojicon

自述文件指出,必须使用活动布局层次结构的最顶层视图来初始化弹出窗口。

我的应用是通过片段实现的。

这是我用于测试的代码:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.overview1_layout, container,
            false);

    // Give the topmost view of your activity layout hierarchy. This will be used to measure soft keyboard height
    EmojiconsPopup popup = new EmojiconsPopup(view, getActivity());

    //Will automatically set size according to the soft keyboard size        
    popup.setSizeForSoftKeyboard();

    popup.showAtBottom();


    return view;
}
Run Code Online (Sandbox Code Playgroud)

如果运行此代码,我将在logcat中收到以下错误:

11-02 22:37:16.685: E/AndroidRuntime(30363): java.lang.RuntimeException: Unable to resume activity {com.Testing.full/com.Testing.full.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not …
Run Code Online (Sandbox Code Playgroud)

android view fragment

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

Android Studio 设备监视器错误

我在 Mac OS 上安装了 Java 9。Android Studio 运行良好,但我无法打开设备监视器。

我收到以下错误:

/Users/tobias/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/monitor ; exit;
Tobiass-MBP:~ tobias$ /Users/tobias/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/monitor ; exit;
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/Users/tobias/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/lib/monitor-x86_64/plugins/org.eclipse.osgi_3.8.2.v20130124-134944.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in …
Run Code Online (Sandbox Code Playgroud)

java android eclipse-plugin android-device-monitor

5
推荐指数
0
解决办法
401
查看次数

动态设置货币符号

在我的应用程序中,有很多文本视图包含货币符号.

现在我希望用户设置符号.我创建了一个共享首选项并添加了所有现有货币.不幸的是,那里有大约20种不同的货币.

因此,我正在努力如何在我的所有文本视图中动态更改货币符号.我可以为每个创建一个大的switch case语句(有20个案例),但这会极大地破坏我的代码.

是否有另一种技术可以改变符号.例如,在不同语言的xml文件的帮助下......

android textview

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

ArrayList 的持久化存储

我在 Android 中有以下 ArrayList:

private ArrayList<Integer> Array= new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)

它将通过 add() 随着时间的推移而增长 它将大约包含多达 50 个元素。

我想将它持久存储。我在考虑 xml、sharedpreferences 和 DB,但我不确定最好的方法是什么。

android arraylist sharedpreferences

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

如何在ICS/JB中增加ProgressBar的高度

我在我的一个小部件中使用Android进度条:

<ProgressBar
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/progressBarStyleHorizontal"
        android:id="@+id/progressbar_Horizontal"
        android:max="100"/>
Run Code Online (Sandbox Code Playgroud)

在Android 2.x中它看起来很好,如下图所示.我在条形码本身上写了%.

Android 2.x中的ProgressBar

但是,如果我改变Android Manifest

机器人:targetSdkVersion

到"15"进度条看起来完全不同.它现在是一条细蓝线而不是条形.问题是我在进度条上面写了一些文字,特别是进度的百分比.因此,当酒吧很薄,这看起来很奇怪.

我无法弄清楚如何再次增加杆的高度,例如50dp.如果我尝试android:layout_height ="50dp"它仍然保持相同的薄.

android android-4.0-ice-cream-sandwich progress-bar

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

Android 4.1.2不显示菜单按钮

我的应用程序提供了一个菜单,单击Android菜单按钮即可访问该菜单.随着Google从3.0开始删除硬件菜单按钮,屏幕上会出现一个软件按下的按钮(通常为3个点)来访问菜单.

很多使用谷歌Nexus手机的用户现在都抱怨说,自从他们更新到4.1.2后,菜单按钮就没出现了.

这里的代码:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, 0, Menu.NONE, this.getString(R.string.setting));
        menu.add(0, 1, Menu.NONE, this.getString(R.string.config));
        return super.onCreateOptionsMenu(menu);
    }
Run Code Online (Sandbox Code Playgroud)

我还需要更改什么才能将按钮带回4.1.2?

android menu

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