나는 recyclerview에 대한 매우 제한된 지식으로 안드로이드에 뛰어 올랐다. 나는 AA 비트를 사용하지만, 다음과 같은 코드 me.Check와 onBindViewHolder.Please 곰 내부의 텍스트를 설정하는 상황에 직면했다 :RecyclerView 설정 텍스트
[
{
"restaurantSubscriptionType_Id": 1,
"noOfDaysPlan": "1 Day Trial Meal",
"restaurantSubscriptionEntity": [
{
"restaurantSubscriptionId": 39,
"subscriptionPlan": "Breakfast & Lunch",
"subscriptionImagePath": null,
"subscriptionDays": 1,
"subscriptionAmount": 150,
"restaurant_Subscription_Type_Id": 1
}
],
"restaurantId": 224
},
{
"restaurantSubscriptionType_Id": 2,
"noOfDaysPlan": "5 Days Weekly Plan",
"restaurantSubscriptionEntity": [
{
"restaurantSubscriptionId": 40,
"subscriptionPlan": "Breakfast & Lunch",
"subscriptionImagePath": null,
"subscriptionDays": 5,
"subscriptionAmount": 650,
"restaurant_Subscription_Type_Id": 2
},
{
"restaurantSubscriptionId": 41,
"subscriptionPlan": "Only Lunch",
"subscriptionImagePath": null,
"subscriptionDays": 5,
"subscriptionAmount": 500,
"restaurant_Subscription_Type_Id": 2
}
],
"restaurantId": 224
}
]
내가 pojo2schema 있습니다
1.이 여기에 JSON,이다 사이트
2.RestaurantSubscriptionEntity
public class RestaurantSubscriptionEntity {
private Integer restaurantSubscriptionId;
private String subscriptionPlan;
private String subscriptionImagePath;
private Integer subscriptionDays;
private Long subscriptionAmount;
private Integer restaurantSubscriptionTypeId;
public RestaurantSubscriptionEntity(){
}
public Integer getRestaurantSubscriptionId() {
return restaurantSubscriptionId;
}
public void setRestaurantSubscriptionId(Integer restaurantSubscriptionId) {
this.restaurantSubscriptionId = restaurantSubscriptionId;
}
public String getSubscriptionPlan() {
return subscriptionPlan;
}
public void setSubscriptionPlan(String subscriptionPlan) {
this.subscriptionPlan = subscriptionPlan;
}
public String getSubscriptionImagePath() {
return subscriptionImagePath;
}
public void setSubscriptionImagePath(String subscriptionImagePath) {
this.subscriptionImagePath = subscriptionImagePath;
}
public Integer getSubscriptionDays() {
return subscriptionDays;
}
public void setSubscriptionDays(Integer subscriptionDays) {
this.subscriptionDays = subscriptionDays;
}
public Long getSubscriptionAmount() {
return subscriptionAmount;
}
public void setSubscriptionAmount(Long subscriptionAmount) {
this.subscriptionAmount = subscriptionAmount;
}
public Integer getRestaurantSubscriptionTypeId() {
return restaurantSubscriptionTypeId;
}
public void setRestaurantSubscriptionTypeId(Integer restaurantSubscriptionTypeId) {
this.restaurantSubscriptionTypeId = restaurantSubscriptionTypeId;
}
3.DemoItemAll :
01 onBindView 안에 지금 여기public class DemoAdapter extends RecyclerView.Adapter<DemoAdapter.MyViewHolder> {
private List<DemoItemAll> demoItemAllArrayList = new ArrayList<>();
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public static class MyViewHolder extends RecyclerView.ViewHolder {
private TextView title_tv,price_tv;
private Button drop_down_button;
public MyViewHolder(View itemView) {
super(itemView);
title_tv = (TextView) itemView.findViewById(R.id.day_plan_demo_tv_id);
price_tv = (TextView) itemView.findViewById(R.id.price_demo_tv_id);
drop_down_button = (Button) itemView.findViewById(R.id.demo_drop_down_btn_id);
}
}
public DemoAdapter(List<DemoItemAll> demoItemAllArrayList) {
this.demoItemAllArrayList = demoItemAllArrayList;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.demo_adapter, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
DemoItemAll demoItemAll=new DemoItemAll();
//noOfDays
holder.title_tv.setText(demoItemAll.getNoOfDaysPlan());
}
@Override
public int getItemCount() {
return demoItemAllArrayList.size();
}
}
을 RecyclerView
확장개4.Here 내 클래스는, 나는 액세스 할이 있지만 "subscriptionAmount는" 이 RestaurantSubscriptionEntity class.How에 속하는 설정해야합니다 그것을
holder.price_tv.setText
// subscriptionAmount.
의 모든 먼저 사용하지 *은'RecyclerView' 문제입니다 필요합니다. 이것은 디자인 문제입니다, 당신은'DemoItemAll'의 DemoItemAllArrayList를'Adapter'에 가지고 있고, 다시'RestaurantSubscriptionEntity'에 대한리스트를 가지고있는 것을 봅니다. 질문은 'DemoItemAll','RestaurantSubscriptionEntity' 또는 둘 모두의 목록을 원하십니까? 설명 해주십시오! 또한 질문을 다시 읽고 가능한 한 간단하고 포괄적으로 시도하십시오. – Abbas
예 해당 필드에 액세스하려는 곳의 RestaurantSubscriptionEntity 목록을 원합니다. – notTdar
그러면 어댑터에'List demoItemAllArrayList'가 있습니까? 어댑터에'RestaurantSubscriptionEntity' 항목의 실제 목록을 전달하지 않는 것이 좋습니다. –
Abbas