我有一个包含不同视图组的recyclerview。
我有一个linearlayout作为recyclerview的一个项目,用于将片段插入其中,因为recyclerview无法直接进行片段视图。我的目标是在加载recylcerview项目之后,当我点击包含片段的(线性布局项目)时,它应该打开一个新的活动。我试过以下,但它不起作用。
volleyinsidemapview.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapFragmentContainer"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="400dp" />
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
RecyclerView.ViewHolder viewHolder;
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
switch (viewType) {
case MAP:
View v1 = inflater.inflate(R.layout.volleyinsidemapview, viewGroup, false);
viewHolder = new PersonViewHoldermap(v1);
break;
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
simhasize = this.udupiwhattoseearray.size();
simhaviewtype = viewHolder.getItemViewType();
switch (simhaviewtype) {
case MAP:
PersonViewHoldermap vh1 = (PersonViewHoldermap) viewHolder;
Caitanyafragment caitanyafragment = new Caitanyafragment();
FragmentTransaction fragmentTransaction = mContext.beginTransaction();
bundle.putInt("id", id);
caitanyafragment.setArguments(bundle);
vh1.frm.setId(mapids[i]);
fragmentTransaction.add(mapids[i], caitanyafragment, maptags[i]).commit();
vh1.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent m = new Intent(v.getContext(), CaitanyaMapview.class);
m.putExtra("id", id);
v.getContext().startActivity(m);
((Activity) context).finish();
Toast.makeText(v.getContext(), "Clicked", Toast.LENGTH_SHORT).show();
}
});
break;