小编Sim*_*mon的帖子

Android SkImageDecoder :: Factory返回null错误

我正在尝试将图像从URL加载到ImageView但发生错误:SkImageDecoder :: Factory返回null.我该如何解决?

这是我的代码:

private class LoadImageFromURL extends AsyncTask<String, Void, Bitmap>{
        ImageView bitmapImgView;
        public LoadImageFromURL(ImageView bmImgView){
            bitmapImgView = bmImgView;
        }

        @Override
        protected Bitmap doInBackground(String... params) {
            // TODO Auto-generated method stub
            String urlStr = params[0];
            Bitmap img = null;
            try {
                URL url = new URL(urlStr);
                InputStream inputStream = url.openConnection().getInputStream();
                //Options bmFactoryOpt = new Options();
                //bmFactoryOpt.inJustDecodeBounds = false;
                img = BitmapFactory.decodeStream(inputStream);          
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated …
Run Code Online (Sandbox Code Playgroud)

android image bitmap

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

ImageView选择器不起作用

我正在我的应用程序中使用几个ImageView形成一个类似于布局的tabhost.当我选择一个项目时,图像将会改变.但是,我试图点击它,没有任何反应!为什么???

activity_main.xml中

<TableLayout 
    android:id="@+id/main_tab_bar"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:stretchColumns="0,1,2,3,4">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView 
            android:id="@+id/news"
            android:clickable="true"
            android:focusable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/main_tab_news_selector"/>
        <ImageView 
            android:id="@+id/share"
            android:clickable="true"
            android:focusable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/main_tab_share_selector"/>
        <ImageView 
            android:id="@+id/camera"
            android:clickable="true"
            android:focusable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/main_tab_camera_selector"/>
        <ImageView 
            android:id="@+id/status"
            android:clickable="true"
            android:focusable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/main_tab_status_selector"/>
        <ImageView 
            android:id="@+id/others"
            android:clickable="true"
            android:focusable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/main_tab_others_selector"/>
    </TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

main_tab_news_selector.xml(其他选择器只是类似)

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item 
        android:drawable="@drawable/ic_action_time"
        android:state_focused="true"
        />
    <item android:drawable="@drawable/ic_action_view_as_list" />

</selector>
Run Code Online (Sandbox Code Playgroud)

android selector

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

标签 统计

android ×2

bitmap ×1

image ×1

selector ×1