我正在尝试将表情符号放在EditText中.我已经设法做到了它工作正常,但当我尝试使用软键盘从EditText删除这些表情符号时我遇到了问题.单击删除按钮,我无法执行此操作.当我插入一个新的ImageSpan时,我为它替换了imageId但是当我尝试删除de图标时,我必须删除所有imageId字符才能删除图像.
String fileName = "emoticon1.png";
Drawable d = new BitmapDrawable(getResources(), fileName);
String imageId = "[" + fileName + "]";
int cursorPosition = content.getSelectionStart();
int end = cursorPosition + imageId.length();
content.getText().insert(cursorPosition, imageId);
SpannableStringBuilder ss = new SpannableStringBuilder(content.getText());
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, cursorPosition, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
content.setText(ss, TextView.BufferType.SPANNABLE);
content.setSelection(end);
Run Code Online (Sandbox Code Playgroud)
我需要通过单击删除按钮来删除表情符号.请问你能帮帮我吗?
谢谢!
我开发了一个应用程序,应该针对Galaxy Nexus和Galaxy S3.两者都有720 x 1280屏幕分辨率,我只在我的应用程序中使用'dp'值.资源存在于'layout-xhdpi'和'drawable-xhdpi'文件夹中.Nexus上的布局看起来非常精细,但是S3上的填充值(以dp为单位)略有偏差.我认为是因为S3的屏幕尺寸更大,密度不同.
如何为Nexus和S3创建单独的文件夹,以便我可以考虑不同的屏幕尺寸?
我正在测试我的应用程序使用NotificationManager发送一个振动的通知.目前,我的清单中没有Vibrate权限.我理解需要它,但是在未经许可的情况下看到设备之间的一些奇怪的行为.
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
Run Code Online (Sandbox Code Playgroud)
我主要测试一个Galaxy S4,它可以让我做振动,即使没有许可设置.这是在Android 4.3上.我刚刚测试了三星Galaxy Nexus,它在尝试振动时产生了运行时异常,表明我没有获得许可.Nexus适用于Android 4.3.
我知道我应该获得许可,但为什么S4似乎并不关心它缺少许可?S4 stock ROM真的不关心权限吗?
这是产生的内部异常,因为它的价值:
Caused by: java.lang.SecurityException: Requires VIBRATE permission
at android.os.Parcel.readException(Parcel.java:1431)
at android.os.Parcel.readException(Parcel.java:1385)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:320)
at android.app.NotificationManager.notify(NotificationManager.java:136)
at android.app.NotificationManager.notify(NotificationManager.java:109)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我全新的Galaxy Nexus上调试我的应用程序.
我做了以下事情:
驱动程序:安装Galaxy驱动程序安装了Galaxy Nexus驱动程序(可以在设备管理器中看到这个,Galaxy在"其他设备"下,Galaxy Nexus在"便携设备"下).
我也在电话中进入了settings-> developer选项并打开了USB Debugging.我还在我的应用程序清单中添加了debug-mod选项.
现在我已经在命令提示符下导航到目录.. ...\Android\android.sdk\platform-tools \我现在尝试执行命令
adb设备.
结果是:"附加设备列表"
然后是一个空白行.
我做错了什么?
我在我的应用程序中使用选项菜单.但是当我在Galaxy Nexus上安装应用程序时,我没有看到选项菜单,因为默认情况下它没有选项菜单按钮.如何在我的应用程序中仅为Galaxy Nexus显示选项菜单按钮?使用其他手机很好,我可以选择菜单.
我为Ice Cream Sandwich创建了一个Android应用程序,并且没有添加任何默认代码(除了更改"Hello World"消息的文本 - 我不能 - 或者不会 - 帮助自己).
我把F5捣碎了.
Nada - 没有附加设备.下拉列表显示"没有附加设备".
所以,我通过Xamarin安装添加的"Open Android Emulator Manager"按钮设置了一个:
我又把F5捣碎了; 同样的问题.它说要从下拉列表中选择一个设备(我忘了明确选择我刚设置的那个).但是......列表中没有任何内容.为什么不?
它现在正在运作; 我估计它没有向我显示我的设备供选择,因为一些Android软件包在后台下载(通过"Android SDK Manager",也由Xamarin添加).
当我"熟悉"Eclipse/Android/Java时,我感觉回来了两年.
android-emulator xamarin.android xamarin galaxy-nexus visual-studio-2013
您好我有一个奇怪的错误,当我想触发Galaxy Nexus(4.0.4)上的方向更改时,它根本不会跳转到该onConfigurationChanged(Configuration)
功能.在HTC Desire(4.0.4)上,它可以在没有相同代码的任何问题的情况下工作.甚至在720p的模拟器上它也可以工作.我尝试更新到Android 4.1,但我仍然遇到同样的问题.
有没有人有同样的问题或任何解决方案?
以下代码适用于获取从相机拍摄的照片的缩略图.我想获得完整的图像,而不仅仅是缩略图.我有三星Galaxy Nexus
private static final int CAMERA_PIC_REQUEST = 1111;
private ImageView mImage;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_camera);
mImage = (ImageView) findViewById(R.id.imageView1);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_PIC_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
mImage.setImageBitmap(thumbnail);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File file = new File(Environment.getExternalStorageDirectory()+File.separator + "image.jpg");
try {
file.createNewFile();
FileOutputStream fo = new FileOutputStream(file);
fo.write(bytes.toByteArray());
fo.close();
} catch (IOException e) …
Run Code Online (Sandbox Code Playgroud)