android:如何从库中选择多个图像然后添加到水平可滚动多个imageView

时间:2015-04-06 07:42:26

标签: android android-imageview

帮我在android中解决这个问题:

android:如何从图库中选择多个图像,然后添加到水平滚动的多个imageView ...!

1 个答案:

答案 0 :(得分:0)

您可以使用this库来选择多张图片

只需使用

调用意图
private void pickImages(){
    final Intent pickIntent = new Intent(this, PickerActivity.class); 
    pickIntent.putExtra(PickerActivity.LIMIT_KEY, 6); // Set a limit , you can skip that if you want no limit

    startActivityForResult(pickIntent, PickerActivity.PICK_REQUEST); //Open gallery
}

在你的onActivityResult中,

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(resultCode, requestCode, data);
    if (requestCode == PickerActivity.PICK_REQUEST && resultCode == RESULT_OK) {
        //No problemo

        final String[] paths = data.getStringArrayExtra(PickerActivity.PICKED_IMAGES_KEY);//Paths for chosen images (Organized)

        //Do what you want with paths

为了横向显示它们,您可以使用显示使用自定义库实现水平列表视图的this链接

使用

中的

<com.devsmart.android.ui.HorizontialListView
    android:id="@+id/listview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ddd"
/>

并使用

设置适配器
HorizontialListView listview = (HorizontialListView) findViewById(R.id.listview);
listview.setAdapter(myAdapter);