我开发了加载所有可用优惠券的优惠券页面。但我还需要在其中加入幻灯片。
Recyclerview包括2个主要布局:
我目前的代码仅用于将cardview加载到recyclerview。
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by venkataprasad on 02-01-2015.
*/
public class VoucherDataAdapter extends RecyclerView.Adapter<VoucherDataAdapter.ViewHolder> {
private static ArrayList<FeddProperties> dataSet;
public VoucherDataAdapter(ArrayList<FeddProperties> os_versions) {
dataSet = os_versions;
}
@Override
public VoucherDataAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
// create a new view
View itemLayoutView = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.card_view_horizontal, null);
// create ViewHolder
ViewHolder viewHolder = new ViewHolder(itemLayoutView);
return viewHolder;
}
@Override
public void onBindViewHolder(VoucherDataAdapter.ViewHolder viewHolder, int i) {
FeddProperties fp = dataSet.get(i);
viewHolder.tvVersionName.setText(fp.getTitle());
viewHolder.iconView.setImageResource(fp.getThumbnail());
viewHolder.feed = fp;
}
@Override
public int getItemCount() {
return dataSet.size();
}
// inner class to hold a reference to each item of RecyclerView
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView tvVersionName;
public ImageView iconView;
public FeddProperties feed;
public ViewHolder(View itemLayoutView) {
super(itemLayoutView);
tvVersionName = (TextView) itemLayoutView
.findViewById(R.id.tvVersionName);
iconView = (ImageView) itemLayoutView
.findViewById(R.id.iconId);
itemLayoutView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), VoucherDetailActivity.class);
v.getContext().startActivity(intent);
//Toast.makeText(v.getContext(), "os version is: " + feed.getTitle(), Toast.LENGTH_SHORT).show();
}
});
}
}
}
如果您有任何建议,请与我们联系。先谢谢!
答案 0 :(得分:1)
在堆栈RecyclerView with multiple view type
上查看此答案您需要实施double foo (const string& a, const C& b, string& d);
double d = foo(x, y, z); // double d ??
void foo(const string& a, const C& b, double& d, string& s)
{
cout << "IN/OUT string d maybe string s?" << endl;
}
答案 1 :(得分:0)
根据您的问题所述,您需要一个回收者视图,在您列表的其余部分中展示您的slideshow.xml
(可能位于0
}和card_view_horizontal.xml
。
检查this article。
我确定这就是你想要的。