小编aik*_*v95的帖子

如何允许粘贴到空的EditText中?

当我长按空的EditText时(不带非空的确定),不会出现粘贴建议弹出窗口。

XML格式

<EditText
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="right"
    android:textSize="50sp"
    android:inputType="numberDecimal"
    android:id="@+id/text"/>
Run Code Online (Sandbox Code Playgroud)

接触EditText的代码

editText.setRawInputType(InputType.TYPE_NULL);
if (Build.VERSION.SDK_INT >= 11) {
    editText.setTextIsSelectable(true);
} else {
    editText.setFocusable(true);
}
Run Code Online (Sandbox Code Playgroud)

android android-edittext

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

为什么全局变量在不同方法中表现不同?

目标:

  1. 给出字符串(字典)的全局数组,只要在函数中可以计算大小load().
  2. 用功能在屏幕上打印字典print().

我的方法:

创建指向字符串的全局指针,创建字符串数组load()并将本地数组指定给全局指针.

问题:

如果我尝试在内部打印全局数组(以及本地数据)load(),一切都很好,但是在打印的情况下print(),segfault会出现在数组末尾的某处.GDB和valgrind输出对我来说似乎很神秘.我放弃.怎么了?

来源和字典在这里.

码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

// length of the longest word in dictionary
#define LENGTH 45
// dictionary file
#define DICTIONARY "large"

// prototypes
void load(const char* dictionary);
void print(void);

// global dictionary size
int dict_size = 0;
// global dictionary
char **global_dict;

int main(void)
{
    load(DICTIONARY);
    print();
    return 0;  
}

/**
 * Loads dictionary into …
Run Code Online (Sandbox Code Playgroud)

c arrays string variables segmentation-fault

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

抬头通知有时不起作用

我以这种方式发出抬头通知:

Notification.Builder nb = new Notification.Builder(context)
        .setSmallIcon(icon)
        .setContentTitle("Title")
        .setContentText("Content")
        .setDeleteIntent(delete)
        .setPriority(Notification.PRIORITY_HIGH)
        .setVibrate(new long[0]);

notificationManager.notify(1, nb.build()); // TODO hardcode
Run Code Online (Sandbox Code Playgroud)

第一次在测试设备上安装应用程序时,通知会抬头,但是如果我扩展通知区域(抬头仍在运行时)并从那里取消通知,则下次通知不会抬头。重新安装应用程序后,通知会再次提示。请问有什么原因不能使抬头行为保持不变?

notifications android heads-up-notifications

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