小编Dec*_*ome的帖子

使用Matrix旋转后获取坐标的新位置

我想知道如何使用矩阵在旋转后获取矩形内的坐标的新位置.我想做的是:

  1. 定义一个矩形
  2. 在该矩形内定义坐标
  3. 旋转矩形
  4. 旋转后获取坐标的新位置

我无法弄清楚的部分是2和4.任何想法?

android rotation matrix coordinates

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

Android:图库意图返回resultCode == RESULT_CANCELED

我开始打算从图库中选择一张图片,但意图始终返回结果代码RESULT_CANCELED.我已经尝试了很多不同的代码但没有任何帮助让我想到也许我错过了一些东西,比如把东西放在Android清单中的活动中?

我的代码:

// The Intent
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK){
        Uri targetUri = data.getData();
        Bitmap bitmap;
        try {
            bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
            profileImage.setImageBitmap(bitmap);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

会很感激一些帮助;)

android gallery android-intent

6
推荐指数
1
解决办法
5974
查看次数

Imageloader仅在listitem离开屏幕后加载列表中的图像

我有一个listView,其中一个适配器通过ImageLoader类从URL加载图像.问题是,在列表项滚动到屏幕外之前,屏幕上的图像不会显示/加载.

基本上,显示了listView,但在向下滚动并再次向上滚动之前,不会加载任何图像.这适用于列表中的所有项目,在第一次显示它们时,直到您向后滚动它们才会加载图像.

我自己没有写过ImageLoader类,我很难理解为什么图像在第一次显示时没有加载.在队列中尝试了很多不同的东西,但似乎没有任何帮助.

ImageLoader类:

public class ImageLoader {

    //the simplest in-memory cache implementation. This should be replaced with something like SoftReference or BitmapOptions.inPurgeable(since 1.6)
    private HashMap<String, Bitmap> cache=new HashMap<String, Bitmap>();
    private File cacheDir;

    public ImageLoader(Context context){
        //Make the background thead low priority. This way it will not affect the UI performance
        photoLoaderThread.setPriority(Thread.NORM_PRIORITY-1);

        //Find the dir to save cached images
        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
            cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"LazyList");
        else
            cacheDir=context.getCacheDir();
        if(!cacheDir.exists())
            cacheDir.mkdirs();
    }

    final int stub_id=R.drawable.nopic;

    public void DisplayImage(String url, Activity activity, ImageView imageView, ProgressBar …
Run Code Online (Sandbox Code Playgroud)

url android image adapter

5
推荐指数
1
解决办法
3147
查看次数

如何使用XmlPullParser获取节点值

我试图从XmlPullParser获取XML的值,但无法达到我想要的值.XML结构类似于Android Strings.xml:

<string name="value"> 1 </string>
Run Code Online (Sandbox Code Playgroud)

我可以从XML获得"string","name"和"value"但无法达到实际值"1".似乎XmlPullParser仅适用于这样的结构:

<value> 1 </value>
Run Code Online (Sandbox Code Playgroud)

我是否需要使用其他解析器,或者是否有办法以某种方式达到"1"(上面的值)?

谢谢!

android xmlpullparser

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