I try to implement a server request, and then delete the ListView element that the user clicked on. During the request to the server, the ProgressBar is added to the View line; its animation does not work (the ProgressBar becomes visible, but does not rotate). ListView is in Fragment, which appears with some user actions.

Initialization code of the View ListAdapter's initialization:

private void createNewView(final UserInfo userInfo, final int position) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View rowView = inflater.inflate(R.layout.listadapter_row_item, null, false); TextView mainText = (TextView) rowView.findViewById(R.id.dutyUsersListadapterMainTextview); mainText.setText(userInfo.lastname); TextView additionalText = (TextView) rowView.findViewById(R.id.dutyUsersListadapterAdditionalTextview); additionalText.setText(String.format("%s %s", userInfo.firstname, userInfo.middlename)); mViews.add(rowView); } 

Display the ProgressBar in the ListView row:

 mUsersList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) { final ProgressBar pb = (ProgressBar) view.findViewById(R.id.adapter_row_deleting_progressbar); pb.setVisibility(View.VISIBLE); RestClient.getInstance().addUser(selectedUser.id, new TextHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { pb.setVisibility(View.GONE); mUsersListAdapter.setEnabled(position, true); } @Override public void onSuccess(int statusCode, Header[] headers, String responseString) { pb.setVisibility(View.GONE); view.setAnimation(AnimationUtils.loadAnimation(activity, R.anim.move_to_left_animation)); new Handler() {{ postDelayed(new Runnable() { @Override public void run() { mUsersListAdapter.removeItem(position); activity.resetFragmentsData(); } }, 500); }}; } }); } }); 

Source code of the listadapter_row_item layout file:

 <ImageView android:layout_weight=".2" android:layout_width="0dp" android:layout_height="@dimen/userlist_photo_height" android:id="@+id/listadapterImage" android:src="@drawable/empty_user_photo" /> <LinearLayout android:orientation="vertical" android:layout_weight=".6" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Lastname" android:id="@+id/listadapterMainTextview" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Firstname Middlename" android:id="@+id/usersListadapterAdditionalTextview" /> </LinearLayout> <RelativeLayout android:orientation="vertical" android:layout_weight=".2" android:layout_width="0dp" android:layout_height="@dimen/duty_userlist_photo_height" android:weightSum="1" android:gravity="center_vertical|center_horizontal"> <ProgressBar style="?android:attr/progressBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/adapter_row_deleting_progressbar" android:indeterminate="true" android:visibility="gone" /> </RelativeLayout> 

  • You don't seem to be trying to make him turn ... - Yuriy SPb
  • And if without android:visibility="gone" for the progress bar, then it rotates? - xkor
  • you somehow incorrectly use ListView. Why do you keep your View in the mViews list? - Vladyslav Matviienko

0