问题将图片URL加载为毕加索的片段

时间:2019-04-09 15:40:46

标签: java picasso

我不知道要在get()中的Picasso.get()中放入什么。我已经尝试过get(getActivity())get(getContext()),但是它们不起作用。它不是get(this),因为它是我正在处理的片段。

public class ManagerEotm extends Fragment {

private Button ChooseWinner;
private Button elections;
private static final int PICK_IMAGE_REQUEST = 1;
private CheckBox uploadWinner;
private EditText month;
private ImageView winnerPicture;
private ProgressBar progressBar;
private Uri imageUri;
private Context context;


@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view =  inflater.inflate(R.layout.manager_eotm, container, false);


    uploadWinner = view.findViewById(R.id.boxUpload);
    month = view.findViewById(R.id.etMonth);
    winnerPicture = view.findViewById(R.id.ivWinner);
    progressBar = view.findViewById(R.id.progressBar);
    ChooseWinner = view.findViewById(R.id.btnChooseWinner);


    return view;

}

private void openFileChooser(){
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intent, PICK_IMAGE_REQUEST);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
        imageUri = data.getData();
        Picasso.get().load(imageUri).into(winnerPicture);

    }
}

1 个答案:

答案 0 :(得分:0)

最新的Picasso已从with()更改为get()。确保已将其添加到build.gradle中。

implementation 'com.squareup.picasso:picasso:2.71828'