我有这段代码
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent});
startActivityForResult(chooserIntent, 1);
获取图像后我应该添加什么才能进行裁剪
答案 0 :(得分:0)
您应该添加a library to your project that handles image cropping,然后将该库与您startActivityForResult()
电话中提供的图片一起使用。
Android does not have an image-cropping Intent
,并且不要求任何尊重ACTION_PICK
,ACTION_GET_CONTENT
或ACTION_OPEN_DOCUMENT
的活动支持一些未记录的附加内容来为您处理图像裁剪。< / p>
答案 1 :(得分:0)
你需要有这样的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""/>
</LinearLayout>
适配器类
import android.content.Intent;
import android.graphics.drawable.Drawable;
public class CropOption {
public CharSequence title;
public Drawable icon;
public Intent appIntent;
}
适配器xml
private DBManager dbManager;
private ListView listView;
private SimpleCursorAdapter adapter;
final String[] from = new String[] { DatabaseHelper._ID,
DatabaseHelper.IDEA, DatabaseHelper.DESC, DatabaseHelper.STAGE};
final int[] to = new int[] { R.id.id, R.id.idea, R.id.desc, R.id.status };
dbManager = new DBManager(this);
dbManager.open();
Cursor cursor = dbManager.fetch();
listView = (ListView) findViewById(R.id.list_view);
listView.setEmptyView(findViewById(R.id.empty));
adapter = new SimpleCursorAdapter(this, R.layout.activity_view_record, cursor, from, to, 0);
adapter.notifyDataSetChanged();
listView.setAdapter(adapter);
pojo class
{{1}}