ImageView don't load second image

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


ImageView don't load second image



I try to dynamically add and remove xml view. When add one view it works fine, but when add another view ImageView don't load image and button doesn't work.


LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
vp.gravity= Gravity.CENTER;


LayoutInflater ltInflater = getLayoutInflater();
View view = ltInflater.inflate(R.layout.publication_image, linearLayout, true);
ImageView iv = view.findViewById(R.id.publicationImageView);
ImageButton deleteButton = view.findViewById(R.id.deleteButton);
deleteButton.setOnClickListener(deleteClickListener);

iv.setImageURI(fileUri);
listView.add(view);
listDeletButton.add(deleteButton);

EditText editText = new EditText(this);
editText.setLayoutParams(vp);
editText.setHint("Введите текст");
editText.setTextSize(15);
editText.setBackground(null);
linearLayout.addView(editText);
listEditText.add(editText);

View.OnClickListener deleteClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
int position = listDeletButton.indexOf(v);
linearLayout.removeView(listEditText.get(position));
listEditText.remove(position);
linearLayout.removeView(listView.get(position));
listView.remove(position);
listData.remove(position);
listDeletButton.remove(position);
} catch (IndexOutOfBoundsException e){
e.printStackTrace();
}
}
};









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived