在我的应用程序中,有一个注册屏幕,我不希望用户能够将文本复制/粘贴到该EditText字段中.我已经设置了onLongClickListener每个,EditText以便显示复制/粘贴/输入方法和其他选项的上下文菜单不显示.因此,用户将无法复制/粘贴到"编辑"字段中.
OnLongClickListener mOnLongClickListener = new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// prevent context menu from being popped up, so that user
// cannot copy/paste from/into any EditText fields.
return true;
}
};
Run Code Online (Sandbox Code Playgroud)
但是,如果用户启用了除Android默认设置之外的第三方键盘,则可能出现问题,该键盘可能具有复制/粘贴按钮或可能显示相同的上下文菜单.那么如何在该场景中禁用复制/粘贴?
如果还有其他方法可以复制/粘贴,请告诉我.(可能还有如何禁用它们)
任何帮助,将不胜感激.
我已经signed-google_ion-ota-14721.zip为我的HTC手机下载并编译了带有图像的Android 2.1版本.编译成功完成,因此系统映像闪烁.如何使用系统签名签署我自己的Android应用程序?
有人可以描述使用系统签名签署用户应用程序的整个过程,因为我对签名过程完全不熟悉.
硬编码onCreate()中的setZoom()感觉非常陈旧,我想通过最初使MapView设置缩放直到所有GeoPoints/OverlayItems在地图上可见来增强用户体验.
怎么能自动神奇地完成?
我正在开发一个Android应用程序,我必须支持所有不同的屏幕尺寸和密度.所以我为布局创建了不同的文件夹:layout-small layout-large和layout.
然后我为图像创建了不同的文件夹:ldpi, mdpi和hdpi.在所有可绘制文件夹中,图像必须具有不同的大小?我问这个原因我有一个屏幕尺寸大且密度适中的手机,显示的图像会更小而且尺寸不合适?
我在使用cygwin make.exe版本(重新)构建时遇到此错误:3.81.
Error : *** target pattern contains no `%'.
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改我的ListView上的字体(颜色和大小)和背景.我想用不在xml上的代码行来改变它.我的列表视图如下:xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="18sp" android:text="@string/hello">
</TextView>
Run Code Online (Sandbox Code Playgroud)
我的代码是
public class NewsActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ArrayAdapter listItemAdapter = new ArrayAdapter( this,android.R.layout.simple_list_item_1, v_itemList );
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,ynetList));
View v=getListView() ;
ListView lv = getListView();
Run Code Online (Sandbox Code Playgroud)
接下来是什么?请根据我的代码给我一个例子
我一直试图让android来抖动活动的背景图片 - 到目前为止还没有成功.我不知道出了什么问题.
这就是我做的:
我的活动布局的根元素是LinearLayout:
<LinearLayout android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:gravity="center_horizontal"
android:background="@drawable/background_dither">
Run Code Online (Sandbox Code Playgroud)
我添加了@ drawable/background_dither作为背景图片.我在drawable-hdpi中放了一个XML文件"background_dither.xml",其中包含以下内容:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/backimg"
android:src="@drawable/background"
android:dither="true"
android:antialias="true" />
Run Code Online (Sandbox Code Playgroud)
它引用了drawable-hdpi中的实际图像background.png.包含大颜色渐变的图像确实会显示,但颜色条纹很重.根据我从SDK中学到的知识,可以通过使用/上面的代理图像定义以及指定android:dither ="true"来减轻这种影响.然而,这绝对没有效果.
我错过了什么让抖动工作?
EDIT2:在没有任何建议的方法有助于摆脱色带之后,在阅读了Romain Guy的这篇博文之后, 我有了检查我的PNG背景是否有alpha通道的想法.它没有.添加一个之后,android实际上似乎使用了RGB8888,正如帖子中所述并且条带消失了(也是为2.2).仍然想知道为什么其他方法不起作用.
EDIT3:必须确保PNG不仅具有alpha通道,而且至少有一个具有alpha值的像素!= FF,否则android构建工具将再次将该位图剥离到没有alpha通道的索引调色板.
有没有办法判断软键盘是否显示在活动中?
我试过了
InputMethodManager manager = (InputMethodManager)
getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
manager.isActive(v)
Run Code Online (Sandbox Code Playgroud)
但isActive仅在第一次显示键盘之前返回false,但如果kb出现然后被解除,则isActive也返回true.
那么有没有其他方法来检查这个问题.
谢谢
我有一个在图像上的XML for Pinch Zoom功能中定义Activity的自ImageView定义.现在,我的问题是我想Bitmap从Pinch Zoom功能中获取缩放比例.例如,如果用户对图像进行缩放,那么我想将图像的确切大小和位置存储为位图.
这是我在XML中声明的自定义ImageView.
<com.cam.view.PinchZoom_ImageView
android:id="@+id/gallery_selected_image_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/icon"
android:scaleType="center"
/>
Run Code Online (Sandbox Code Playgroud)
更新:
我正在尝试下面的代码来获取缩放的图像,但它返回一个空白位图.
pinchZoom.setDrawingCacheEnabled(true);
pinchZoom.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
pinchZoom.layout(0, 0, pinchZoom.getMeasuredWidth(), pinchZoom.getMeasuredHeight());
pinchZoom.buildDrawingCache(true);
Bitmap_gallery_Item = Bitmap.createBitmap(pinchZoom.getDrawingCache());
pinchZoom.setDrawingCacheEnabled(false);
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢