我正在使用改造来解析服务器中的json数组。 我希望用户在recyclerview中自定义JSON输入 比如他们点击几秒钟就会弹出一个删除选项,用于特定的json对象!在recyclerview中,然后通过意图将其传递给另一个活动,这里我的意图活动是不完整的。 提前谢谢
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>