i am developing a shopping app in that app i need to list the products that are uploaded by the seller and i need to display those items in list view with limited information.
once buyer click on the particular item it need to naviagte to another page and it needs to show more details about that product.
i have generated a list using recyclerview in android studio.if i click on the one dataset in that listview it has to navigate to another page and has to display more information about the dataset that is cliked by the user.
i have tried the following code segment but it wont work .
public class getItem extends AppCompatActivity {
private RecyclerView mAd_list;
private DatabaseReference mDatabase;
Button buy;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_items);
mDatabase = FirebaseDatabase.getInstance().getReference().child("Items");
mAd_list = (RecyclerView) findViewById(R.id.ad_list);
mAd_list.setHasFixedSize(true);
mAd_list.setLayoutManager(new LinearLayoutManager(this) {
});
mAd_list.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intentRegistration=new Intent(getApplicationContext(),DisplayListDetailActivity.class);
startActivity(intentRegistration);
}
});
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Item, AdViewHolder>firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Item, AdViewHolder>(
Item.class,
R.layout.view_item,
AdViewHolder.class,
mDatabase
) {
@Override
protected void populateViewHolder(AdViewHolder viewHolder, Item model, int position) {
viewHolder.setTitle(model.getName());
viewHolder.setDesc(model.getPrice().toString());
viewHolder.setImage(getApplicationContext(), model.getImage());
}
};
mAd_list.setAdapter(firebaseRecyclerAdapter);
}
}
class AdViewHolder extends RecyclerView.ViewHolder{
View mView;
public AdViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setTitle(String title) {
TextView post_title = (TextView) mView.findViewById(R.id.post_title);
post_title.setText(title);
}
public void setDesc(String desc){
TextView post_desc = (TextView) mView.findViewById(R.id.post_desc);
post_desc.setText(desc);
}
public void setImage (Context ctx, String image){
ImageView post_image = (ImageView) mView.findViewById(R.id.post);
Picasso.with(ctx).load(image).into(post_image);
}
}
interface
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="324dp"
android:id="@+id/post_desc"
android:text="The Ad Description Goes Here"
android:paddingTop="260dp"
android:textSize="16dp"
android:paddingBottom="15dp"
android:paddingLeft="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/post"
android:scaleType="centerCrop"
android:adjustViewBounds="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/post_title"
android:text="Ad Title Goes Here"
android:paddingTop="220dp"
android:textSize="16dp"
android:paddingLeft="10dp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>