Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Android中从位图生成纹理_Android_Bitmap - Fatal编程技术网

无法在Android中从位图生成纹理

无法在Android中从位图生成纹理,android,bitmap,Android,Bitmap,我目前正在开发一个android应用程序,到目前为止,我使用EclipseAndroid模拟器进行测试 今天我决定在我的手机(小米mi2)上试用,但当我用午餐时(通过usb调试),我面临两个问题: 我有一个背景图片,模拟器显示完美,但它没有出现在我的手机上-一个黑色的背景显示 可能这是前一个的问题,LogCat显示了一些错误: 03-01 22:18:35.599:E/OpenGLRenderer(1109):无法从位图生成纹理 03-01 22:18:35.629:E/SpannableStr

我目前正在开发一个android应用程序,到目前为止,我使用EclipseAndroid模拟器进行测试

今天我决定在我的手机(小米mi2)上试用,但当我用午餐时(通过usb调试),我面临两个问题:

  • 我有一个背景图片,模拟器显示完美,但它没有出现在我的手机上-一个黑色的背景显示

  • 可能这是前一个的问题,LogCat显示了一些错误:

  • 03-01 22:18:35.599:E/OpenGLRenderer(1109):无法从位图生成纹理
    03-01 22:18:35.629:E/SpannableStringBuilder(1109):SPAN_EXCLUSIVE_EXCLUSIVE SPAN不能有零长度

    活动代码:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="480dip"
    android:layout_marginTop="10dip"
    android:background="@drawable/bg">
    <EditText
        android:id="@+id/eu_un"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:hint="@string/enter_user_name" >
    </EditText>
    
    <EditText
        android:id="@+id/eu_pw"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/eu_un"
        android:ems="10"
        android:hint="@string/enter_password"
        android:inputType="textPassword|textPersonName" />
    
    <Button
        android:id="@+id/nu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="134dp"
        android:text="@string/signup" />
    
    <Button
        android:id="@+id/eu_signin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/eu_pw"
        android:layout_centerHorizontal="true"
        android:text="@string/login" />
    
    <Button
        android:id="@+id/exit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/eu_signin"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="61dp"
        android:text="@string/exit" />
    
    </RelativeLayout>
    

    这是一个奇怪的错误。我做了一些搜索,发现了一些类似的帖子,似乎暗示这与设备的键盘设置有关:

    他们中的大多数人在问题中都有特定的电话

    如果你搜索,还有很多


    我知道这并没有提供您希望的答案,但理想情况下,它会让您朝着正确的方向前进。

    我在我的nexus5 Android L版本中遇到了同样的错误。 在我的例子中,我注释了两行来修复它。 ( //opt.inpurgable=true; //opt.inInputShareable=true; ) 希望对你有用。 祝你好运

    下面是我的代码:

    ImageView image=(ImageView)findviewbyd(R.id.ImageView);
    Options=new-BitmapFactory.Options();
    opt.inPreferredConfig=Bitmap.Config.RGB_565;
    //opt.inpurgable=true;
    //opt.inInputShareable=true;
    InputStream is=getResources().openRawResource(R.raw.error\u nothing\u app);
    位图位图=BitmapFactory.decodeStream(is,null,opt);
    is.close();
    BitmapDrawable drawable=新的BitmapDrawable(getResources(),位图);
    
    image.setImageDrawable(可绘制)我在genymotion API 16+上的模拟设备上也遇到了这个错误

    我的问题的解决方案是用png图像替换gif图像


    多亏了

    当图像的位图由于回收而丢失时,或者在硬件加速(和openGLRenderer)的情况下,当OpenGL上下文丢失时,会发生这种情况。您的代码是什么样子的?图像的代码?活动中的代码。请参阅编辑的文章。谢谢你还有
    .java
    文件吗?谢谢,span错误与我的快捷键键盘有关(我从问题中删除了它)。位图错误与背景有关image@user1692261我把问题往后退了退,因为你删掉那一行会使我的答案无效——人们会认为这是一个糟糕的回答。
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        un = (EditText) findViewById(R.id.eu_un);
        pw = (EditText) findViewById(R.id.eu_pw);
        nu = (Button) findViewById(R.id.nu);
        eu = (Button) findViewById(R.id.eu_signin);
        exit = (Button) findViewById(R.id.exit);
        ma = this;
    
        nu.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                newUser();
            }
        });