小编Ben*_*enG的帖子

Android系统.按标签查找视图

我有一个动态创建的视图,想要通过标签找到它,这可能吗?我知道这个功能findViewById,标签有类似之处吗?

tags android view find

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

Android谷歌地图.按地址添加标记

我在android应用程序中添加了地图,并希望在地图上按地址添加标记.有可能的?我已经尝试过很长时间了Geocoder,但是我得到了错误Service not Available.

我的代码:

Geocoder geocoder = new Geocoder(getBaseContext());
        List<Address> addresses = null;

        try {
            addresses = geocoder.getFromLocationName(event.getPlace(), 20);
            System.out.println(addresses);
//          for (int i = 0; i < addresses.size(); i++) { // MULTIPLE MATCHES
//
//              Address addr = addresses.get(i);
//
//              double latitude = addr.getLatitude();
//              double longitude = addr.getLongitude(); // DO SOMETHING WITH
//                                                      // VALUES
//
//              System.out.println(latitude);
//              System.out.println(longitude);
//
//          }
        } catch (IOException e) {
            // TODO Auto-generated catch block …
Run Code Online (Sandbox Code Playgroud)

android google-maps

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

Android setBitmap to canvas

我想将画布转换为图像并将其保存在设备上.但是当我将位图设置为画布时,我得到了错误java.lang.UnsupportedOperationException.我的完整代码:

public class SingleTouchEventView extends View {
private Paint paint = new Paint();
private Path path = new Path();


public SingleTouchEventView(Context context, AttributeSet attrs) {
    super(context, attrs);

    paint.setAntiAlias(true);
    paint.setStrokeWidth(6f);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.BEVEL);
}

@Override
protected void onDraw(Canvas canvas) {
    canvas.drawPath(path, paint);
    canvas.drawCircle(50, 50, 3, paint);
    Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
    canvas.setBitmap(bitmap);
    try {

        File file = new File(Environment.getExternalStorageDirectory() + "/image.jpg");
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(file));
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
} …
Run Code Online (Sandbox Code Playgroud)

android canvas image

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

标签 统计

android ×3

canvas ×1

find ×1

google-maps ×1

image ×1

tags ×1

view ×1