小编Viv*_*kur的帖子

如何在WebView中启用缩放控件和缩放缩放?

Android的默认浏览器应用程序在您滚动时显示缩放控件,并允许缩放缩放.如何为自己的Webview启用此功能?

我试过了:

webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
Run Code Online (Sandbox Code Playgroud)

但是这两个功能都没有得到启用.顺便说一句WebChromeClient,WebViewClient如果有所作为,我会为Webview 设置一个和一个.

谢谢!

android webview

119
推荐指数
6
解决办法
9万
查看次数

以编程方式将ImageView的重力设置为android中心

我想用以下代码将Imageview数组的重力,ImageIcons [i]设置到中心,

ImageIcons[i] = new ImageView(this);
ImageIcons[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
layout.addView(ImageIcons[i]);
Run Code Online (Sandbox Code Playgroud)

在设定引力时我被困住了.我要求SO人员指导我.

谢谢

android center dynamic gravity android-imageview

39
推荐指数
2
解决办法
6万
查看次数

String.xml或Constants类

在设计Android应用程序时,以下更好的方法是什么?

  1. 将所有String常量放在res/values/Strings.xml 或中
  2. 创建一个类似Constant.java所有字符串的类public static final

选择哪一个更有效?

android android-xml

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

没有声音来自Android模拟器

我运行了我的应用程序,我无法在Android模拟器上运行声音.我在EclipseAVD Manager中检查并启用了音频播放布尔值.我还进入了Android模拟器中的声音选项并将其放置(放置时没有声音).我选中了一个框,表示所有选择都会产生噪音(仍然没有声音).

我的应用程序使用MediaPlayer该类,我正在运行win7 x64,如果它与它有任何关系.

感谢帮助.

android media-player android-emulator

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

为什么我无法为特定角落创建圆形边框?

在我的android xml布局中,我使用borderframe.xml作为背景来应用边框.

borderframe.xml文件如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke 
        android:width="1dip" 
        android:color="#ffffff"/>
    <solid 
        android:color="#95865F"/>
    <corners 
        android:radius="10px"/>

    <padding 
        android:left="1dp"
        android:right="1dp"
        android:top="1dp"
        android:bottom="1dp"/> 
</shape>
Run Code Online (Sandbox Code Playgroud)

现在,虽然有一个android:radius ="10px"然后它是有效的,但我将圆形形状到特定的角落只有它不起作用.日志猫中没有任何错误消息,但我在eclipse中发现错误,如:

    The graphics preview in the layout editor may not be accurate:
* Different corner sizes are not supported in Path.addRoundRect.
Run Code Online (Sandbox Code Playgroud)

即使该xml文件中没有填充,我也无法看到任何边框.

现在,我该怎么做呢?如果我想为topLeftcorner和bottomLeftCorner创建圆形边框,那么它是什么的解决方案.?谢谢.

android xml-layout

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

Internet连接错误

我有一个连接到Internet的Android应用程序.我正在捕获所有可能的连接方案,并注意到当我没有Internet连接时,UnknownHostException就是thrown.我在这里有点困惑,因为获得UnknownHostException意味着应用程序能够连接到Internet但无法找到给定的URL.

我得到了正确的例外吗?你能解释一下我为什么要UnknownHostException这个?

此外,您能告诉这些场景的具体例外情况:

  • 没有互联网连接时.
  • 无法找到URL时.
  • 当请求超时时.
  • 当网站关闭时.
  • 访问被拒绝时.

如果你能给我更多场景和例外,我也将不胜感激.我必须捕获所有可能的连接并根据连接类型错误显示最合适的消息.

connection android exception-handling exception

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

Resources.getSystem()vs getResources()

我是Android新手,我自己通过网络上的资源学习SDK.

我现在遇到了一个情况.我正在尝试以下代码:

类型1:getResources().getString(android.R.string.cancel);

类型2: Resources.getSystem().getString(android.R.string.cancel);

类型3: getString(android.R.string.cancel);

所有上述方法都返回相同的值.那么这些方法是什么,它们的用例是什么.什么时候使用哪种方法的好方法.请帮帮我.

android

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

android phonegap中的状态栏通知

我在状态栏通知中有一个问题,间隔为10秒.我已经完成了代码,通过创建插件一次显示它.但我想每隔10分钟显示一次.所以我用它每10分钟AlarmManager生成一次通知但是它没有调用类的onReceive(Context ctx, Intent intent)方法FirstQuoteAlarm.我有以下代码用于显示通知和AlarmManager.

public void showNotification( CharSequence contentTitle, CharSequence contentText ) {
    int icon = R.drawable.nofication;
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, contentTitle, when);

    Intent notificationIntent = new Intent(ctx, ctx.getClass());
    PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

    mNotificationManager.notify(1, notification);

      Date dt = new Date();
      Date newdate = new Date(dt.getYear(), dt.getMonth(), dt.getDate(),10,14,dt.getSeconds());
      long triggerAtTime =  newdate.getTime();
      long repeat_alarm_every = 1000;
      QuotesSetting.ON = 1;

       AlarmManager am …
Run Code Online (Sandbox Code Playgroud)

android phonegap-plugins cordova

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

JNI NewByteArray内存泄漏

我有一个处理位图并返回String的Java方法.当我从JNI(VS 2010)调用此方法时,它可以正常工作,但如果我多次调用此方法,则进程的内存会长大,直到崩溃.使用大量内存的指令是:

jbyteArray jBuff = _env->NewByteArray(b->Length);
Run Code Online (Sandbox Code Playgroud)

我的代码:

static jobject staticArray=0;

System::String^ MyClass::ExecuteJavaMethod(System::Drawing::Bitmap^ bmp)
{
    JNIEnv *_env;
    System::String^ out;
    unsigned const char * buff;

    int res = jvm->AttachCurrentThread((void **)&_env, NULL);

    if (jvm->GetEnv((void**) &_env, JNI_VERSION_1_6) != JNI_OK)
    {
        return "GetEnv ERROR";
    }

    //save the bitmap in the stream
    MemoryStream^ ms = gcnew MemoryStream();
    bmp->Save(ms, ImageFormat::Bmp);

    //get the bitmap buffer
    array<unsigned char>^b = ms->GetBuffer() ;

    //unmanaged conversion
    buff = GetUnmanaged(b,b->Length);


    //fill the buffer
    jbyteArray jBuff = _env->NewByteArray(b->Length);       
    _env->SetByteArrayRegion(jBuff, 0, b->Length, (jbyte*) buff);

    //call …
Run Code Online (Sandbox Code Playgroud)

java java-native-interface visual-studio-2010 visual-c++

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

具有null Long的三元表达式中的NullPointerException

为什么下面的代码行产生了NullPointerException

Long v = 1 == 2 ? Long.MAX_VALUE : (Long) null;
Run Code Online (Sandbox Code Playgroud)

我知道正在进行拆箱null,但为什么呢?

注意

Long v = (Long) null;
Run Code Online (Sandbox Code Playgroud)

不会产生异常.

java nullpointerexception

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