0

i'm using retrofit to parse json array from server. i want user to customize JSON input in recyclerview like they tap for a few sec and a remove option will pop up for that particular json object! in recyclerview and then pass it to another activity through intent , here my intent activity is incomplete . thanks in advance

    public class MainActivity extends AppCompatActivity {

        private static final String TAG = MainActivity.class.getSimpleName();
        private View Vm;
         @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.places_recycler_view);
            recyclerView.setLayoutManager(new LinearLayoutManager(this));

            ApiInterface apiService =
                    ApiClient.getClient().create(ApiInterface.class);
            Call<PlaceResponse> call = apiService.getdd();
            call.enqueue(new Callback<PlaceResponse>() {
                @Override
                public void onResponse(Call<PlaceResponse> call, Response<PlaceResponse> response) {
                    int statusCode = response.code();
                    List<place> places = response.body().getPlaces();
                    recyclerView.setAdapter(new PlaceAdapter(places, R.layout.list_item, getApplicationContext()));
                }

                @Override
                public void onFailure(Call<PlaceResponse> call, Throwable t) {
                    Log.e(TAG, t.toString());
                }
            });
    }
    protected void  OnNextButton(View vm){
            Intent intent = new Intent(this, csblow.class);
    intent.putExtra("places",List<place>toString());

     startActivity(intent);
    }
////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/Place_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:minHeight="72dp"
    android:orientation="horizontal"
    android:padding="16dp">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:paddingRight="16dp"
            android:textStyle="bold"

            android:textSize="16sp" />


        <TextView
            android:id="@+id/lat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingRight="16dp"
            />

        <TextView
            android:id="@+id/lng"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="3"
            android:paddingRight="16dp"
            />
        <TextView
            android:id="@+id/needle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="3"
            android:paddingRight="16dp"
            />
    </LinearLayout>


</LinearLayout>

1 Answers1

0

If your want to remove item from RecyclerView with animation you need:

1) remove the item from your adapter.

2) call adapter.notifyItemRemoved(int).

Anton Potapov
  • 1,265
  • 8
  • 11