Open a fragment from a cardView - android

How can i open a fragment from onClick in CardView?
i have a list in Cardview and when i clicked want to show in another fragment.
This is the adapter.class
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView fecha_celula;
public TextView nombre_celula;
public ViewHolder(View itemView) {
super(itemView);
fecha_celula = (TextView) itemView.findViewById(R.id.fecha_celula);
nombre_celula = (TextView) itemView.findViewById(R.id.nombre_celula);
itemView.setOnClickListener(this);
}
#Override
public void onClick(View v) {
Fragment nameAdd = new name_add();
getSupportFragmentManager().beginTransaction().replace(R.id.container, predicaAdd).commit();
}
}
and this is the layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:clickable="true"
android:layout_margin="10dp"
android:id="#+id/card_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:duplicateParentState="true">
<ImageView
android:id="#+id/avatar_celula"
android:src="#drawable/ic_action_celula"
android:scaleType="centerCrop"
android:layout_marginRight="10dp"
android:layout_width="150dp"
android:layout_height="150dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/fecha_celula"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/avatar_celula" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/nombre_celula"
android:layout_below="#+id/fecha_celula"
android:layout_toEndOf="#+id/avatar_celula" />
</RelativeLayout>
I resolve the problem whith the onClick, now my problem is that i can't open another fragment.
how i can call my method in myActivity?

The OnClickListener is not actually used anywhere, you have to connect it to a view, e.g. your itemView in the constructor.
itemView.setOnClickListener(this);
In the onClick() method you can then use getPosition() to get the index of the clicked element.

Related

Recycler View Items Not loading using firebase [duplicate]

This question already has answers here:
FirestoreAdapter not working to populate a Recycler View
(2 answers)
Closed 3 years ago.
ONStart Code
#Override
public void onStart() {
super.onStart();
DatabaseReference cartlistref = FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid()).child("Cart");
FirebaseRecyclerAdapter<Cart, CartViewHolder> adapter = new FirebaseRecyclerAdapter<Cart, CartViewHolder>(
Cart.class,
R.layout.cart_items,
CartViewHolder.class,
cartlistref
) {
#Override
protected void populateViewHolder(CartViewHolder holder, Cart cart, int i) {
holder.pname.setText(cart.getName());
holder.pprice.setText(cart.getPrice());
//holder.quantity.setNumber(cart.getQuantity());
}
};
adapter.notifyDataSetChanged();
recyclerView.setAdapter(adapter);
}
CartViewHolder Code
public class CartViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView pname,pprice ;
public ImageView pimage;
public ElegantNumberButton quantity;
ItemClickListener itemClickListener;
public CartViewHolder(#NonNull View itemView) {
super(itemView);
pname = itemView.findViewById(R.id.pname);
pprice = itemView.findViewById(R.id.pprice);
quantity = itemView.findViewById(R.id.qty);
pimage = itemView.findViewById(R.id.pimage);
}
#Override
public void onClick(View v) {
itemClickListener.onClick(v,getAdapterPosition(),false);
}
public void setItemClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
}
Cart items xml code
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:layout_width="match_parent"
android:padding="16dp"
android:layout_height="160dp"
android:background="?attr/selectableItemBackground"
android:clickable="true">
<ImageView
android:id="#+id/pimage"
android:layout_width="151dp"
android:layout_height="match_parent"
app:srcCompat="#drawable/basket" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="150dp">
<TextView
android:id="#+id/pname"
android:layout_width="match_parent"
android:layout_height="57dp"
android:text="Product Name"
android:textSize="25sp"
android:textAlignment="center"
android:layout_gravity="center"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#android:color/black"
android:textStyle="normal|bold" />
<TextView
android:text="Product price"
android:textSize="18sp"
android:textAlignment="center"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pprice"
android:layout_marginTop="4dp" />
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:textSize="18sp"
android:layout_width="200dp"
android:layout_height="50dp"
android:id="#+id/qty"
android:visibility="visible"
android:layout_marginTop="10dp"
android:layout_gravity="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
Cart Fragment code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fancy="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hackathon.shoppy.fragments.CartFragment">
<RelativeLayout
android:id="#+id/rill"
android:background="#color/colorPrimaryDark"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/totalamt"
android:textSize="20sp"
android:gravity="center"
android:textAlignment="center"
android:textColor="#android:color/white"
android:text="Total Amount = "
android:layout_width="match_parent"
android:layout_height="50dp"/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fancy:layout_constraintBottom_toTopOf="#+id/EditDetails"
fancy:layout_constraintEnd_toEndOf="parent"
fancy:layout_constraintStart_toStartOf="parent"
fancy:layout_constraintTop_toTopOf="parent"
android:layout_below="#+id/rill"
android:layout_above="#+id/checkout"/>
<mehdi.sakout.fancybuttons.FancyButton
android:id="#+id/checkout"
android:layout_width="280dp"
android:layout_height="66dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:textSize="20sp"
fancy:fb_defaultColor="#7ab800"
fancy:fb_radius="10dp"
fancy:fb_text="Proceed To Checkout"
fancy:fb_textColor="#FFFFFF" />
</RelativeLayout>
Firebase Database Structure
Here is the firebase database structure
I have tried the above code
I want to load cart items of a specific user from the firebase database
The view is loading but the recycler view items arent showing up
Also the app is not crashing and no errors in logcat
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fancy:layout_constraintBottom_toTopOf="#+id/EditDetails"
fancy:layout_constraintEnd_toEndOf="parent"
fancy:layout_constraintStart_toStartOf="parent"
fancy:layout_constraintTop_toTopOf="parent"
android:layout_below="#+id/rill"
android:layout_above="#+id/checkout"/>
here is your problem. You are telling recycler view to WRAP CONTENT. problem is, that in moment of creation, content is empty, so recycler view has height zero.
Try to use
android:layout_width="match_parent"
android:layout_height="match_parent"
and experiment with height. But width for sure better to be left as match_parent
I think its because of wrap content, try to fill color in recylerview with blue or something, if you are not able to see then change to match parent

How to implement EmojiTextView in fragment?

I have an emoji in one of my data in cloud firestore. How do I can make the value readable in my fragment,recycleview? When adding old emoji such as 😭, it shows in my recycler view but when ading new emoji such as "🥺". Is it because of my android keyboard or language didn't update? I hope anyone can solve my problem.
ForumAdapter.java
public ForumHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
android.view.View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardviewforumtitle,parent,false);
EmojiCompat.init(new BundledEmojiCompatConfig(v.getContext()));
return new ForumHolder(v);
}
class ForumHolder extends RecyclerView.ViewHolder{
EmojiTextView textViewTitle;
EmojiTextView textViewDescription;
EmojiTextView timeStamp;
/*
TextView textViewTitle;
TextView textViewDescription;
TextView timeStamp;*/
public ForumHolder(View itemView) {
super(itemView);
textViewTitle = itemView.findViewById(R.id.tvTitle);
textViewDescription = itemView.findViewById(R.id.tvDescription);
timeStamp = itemView.findViewById(R.id.tvTimestamp);
textViewTitle.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int position = getAdapterPosition();
// NO_POSITION to prevent app crash when click -1 index
if(position != RecyclerView.NO_POSITION && listener !=null ){
listener.onItemClick(getSnapshots().getSnapshot(position),position);
}
}
});
}
}
Because I got this error
java.lang.ClassCastException: androidx.appcompat.widget.AppCompatTextView cannot be cast to androidx.emoji.widget.EmojiTextView
cardviewforumtitle.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="name"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="description"
android:textSize="15sp" />
<TextView
android:id="#+id/tvTimestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="timestamp"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/profilePic"
android:layout_width="match_parent"
android:layout_height="match_parent"></ImageView>
</LinearLayout>
</LinearLayout>
Try replacing the TextViews with
<androidx.emoji.widget.EmojiTextView
..../>
in the layout.

How to cover complete Background Color in recycler View?

Image Description is here
enter image description here
I did Match Parent for the Layout but then it is divided into several
scrollable sections. How do i fill the remaining bottom background
color of this Recycler View ?
Here is my code for the layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:id="#+id/teacher_relative">
<LinearLayout
android:id="#+id/linr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="6dp"
android:background="#drawable/selector_item_main_menu"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/home_fund_raising" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:shadowColor="#393939"
android:shadowDx="2.0"
android:shadowDy="1.0"
android:shadowRadius="2.0"
android:text="ZED"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/txt_notify"
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/bg_white_circle"
android:gravity="center"
android:layout_marginLeft="77dp"
android:text="0"
android:visibility="gone"
android:textSize="13sp"
android:textColor="#color/red"
android:textStyle="bold" />
Java Code :
recyclerView = findViewById(R.id.recyclerView);
// set a GridLayoutManager with default vertical orientation and 3 number of columns
GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(),3);
recyclerView.setLayoutManager(gridLayoutManager);
I am using Grid Layout
Code for Adapter Class :
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
MyTeacherModel myTeacherModel = myTeacherModelsList.get(position);
holder.imageView.setImageDrawable(mContext.getResources().getDrawable(myTeacherModel.getImages()));
holder.textView.setText(myTeacherModel.getText());
holder.teacher_relative.setBackgroundColor(Functions.getBackColor());
}
#Override
public int getItemCount() {
return myTeacherModelsList.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
public TextView textView, txt_notify;
public ImageView imageView;
DataModel item;
public LinearLayout linr;
RelativeLayout teacher_relative;
public ViewHolder(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(R.id.textView);
imageView = (ImageView) itemView.findViewById(R.id.imageView);
linr = (LinearLayout) itemView.findViewById(R.id.linr);
txt_notify = (TextView) itemView.findViewById(R.id.txt_notify);
teacher_relative = itemView.findViewById(R.id.teacher_relative);
}
}
You should give background to the container view that holds the recyclerview.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/selector_item_main_menu">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/menubar"
android:id="#+id/myRcv"/>
</RelativeLayout>

Accessing element from same layout parent

i have a listview with different components (2 linear layouts and a button) , what i want to do is when i click on a button that's inside one of those linear layouts , i want to access a textview that's inside the other linearlayout , is it possible ?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/listV2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/icon"
android:layout_width="85dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/nom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textCname"
android:textSize="21dp"
android:textStyle="bold" />
<TextView
android:id="#+id/numero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12dp"
android:textColor="#color/textCother"
android:textStyle="italic" />
<TextView
android:id="#+id/ville"
android:layout_width="match_parent"
android:textColor="#color/textCother"
android:layout_height="wrap_content"
android:textSize="12dp"
android:textStyle="italic" />
</LinearLayout>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:visibility="invisible" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
>
<ImageView
android:id="#+id/remove"
android:onClick="contactRemove"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/edit"
android:onClick="contactEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="22dp"/>
<ImageView
android:onClick="contactCall"
android:id="#+id/call"
android:layout_marginLeft="22dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
what i want to do is access the value of android:id="#+id/numero"
when i click on one of the image views
You can set OnClickListener interface provided by View class. Something like this.
Implement listener on your activity class
public class SpinnerActivity extends AppCompatActivity implements
View.OnClickListener
Declare class level variables for your views
private TextView tvNumero;
private ImageView ivRemove, ivEdit, ivContactCall;
Find initialise value in onCreate() method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gildi_spinner);
tvNumero = (TextView) findViewById(R.id.numero)
ivRemove = (ImageView) findViewById(R.id.remove);
ivEdit = (ImageView) findViewById(R.id.edit);
ivContactCall = (ImageView) findViewById(R.id.contactCall);
ivRemove.setOnClickListener(this);
ivEdit.setOnClickListener(this);
ivContactCall.setOnClickListener(this);
}
Implemented class from Onclickistener, where you get on click event for your registered views
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.remove:
case R.id.edit:
case R.id.contactCall:
Toast.makeText(this, tvNumero.getText().toString(), Toast.LENGTH_SHORT).show();
break;
}
}
NOTE : tvNumero.getText().toString() gives you the value of your desired TextView.
UPDATE :
Firstly replace your ListView with RecyclerView
Refer RecyclerView Example tutorial.
Secondly to achieve onClick for your listed items
Refer recyclerview-onclick tutorial.
Pass context when you create your adapter, Use that context to get the inflated view.
Adapter adapter = new Adapter(this);
Then in Adpater Class constructor :
public Adapter(Context context){
context.findViewById(R.id.textview);//consider this as numero textview
}
Then access it as per your requirement. Hope it helps!

How to delete space when I hide a CardView

How can I delete the space when I hide a CardView? I doing an app with android and Firebase and I show the information from firebase in cardviews, but when the info isn't correct the cardview must disappear. The point is that the cardview disappear, but still uses a space in the layout, I've tried the answers in
setVisibility(GONE) view becomes invisible but still occupies space But it doesn't work for me.
#Override
protected void onStart() {
super.onStart();
firebaseAuth.addAuthStateListener(firebaseAuthListener);
final FirebaseRecyclerAdapter<CursosDB, MainActivity.CursosPViewHolder> firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<CursosDB, MainActivity.CursosPViewHolder>(
CursosDB.class,
R.layout.design_row_cursos,
MainActivity.CursosPViewHolder.class,
myRef)
{
#Override
protected void populateViewHolder(MainActivity.CursosPViewHolder viewHolder, final CursosDB Cmodel, int position)
{
String estado = Cmodel.getSTATUS().toString();
if (estado.equals("OK")){
viewHolder.setPhotoURL(getApplicationContext(), Cmodel.getURI());
viewHolder.setTitle(Cmodel.getTITLE());
viewHolder.setCiudad(Cmodel.getPLACE());
viewHolder.setLevel(Cmodel.getLEVEL());
viewHolder.setDur(Cmodel.getDURACION());
viewHolder.setPrice(Cmodel.getCOSTO());
}else{
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) viewHolder.mView.getLayoutParams();
layoutParams.setMargins(0,0,0,0);
viewHolder.mView.setLayoutParams(layoutParams);
viewHolder.mView.setVisibility(View.INVISIBLE);
viewHolder.mView.setVisibility(View.GONE);
//viewHolder.mView.setVisibility(View.GONE);
//Toast.makeText(getApplicationContext(), "Ningún curso aprobado aún", Toast.LENGTH_SHORT).show();
}
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Toast.makeText(getApplicationContext(), Cmodel.getUSERID(), Toast.LENGTH_LONG).show();
//Toast.makeText(getApplicationContext(), Cmodel.getTITLE(), Toast.LENGTH_SHORT).show();
//Toast.makeText(UsersList.this, user_key, Toast.LENGTH_LONG).show();
}
});
}
};
mCourses.setAdapter(firebaseRecyclerAdapter);
}
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/cardview_cursos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:onClick="positionAction"
android:padding="4dp"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingStart="4dp"
android:paddingTop="4dp"
app:cardElevation="4dp">
<LinearLayout android:id="#+id/layout_to_hide"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/Cimg"
android:layout_width="match_parent"
android:layout_height="165dp"
android:scaleType="center"
app:srcCompat="#drawable/knowit_logo" />
<TextView
android:id="#+id/Ctitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/Cimg"
android:layout_marginLeft="14dp"
android:layout_marginStart="14dp"
android:paddingTop="8dp"
android:text="Titulo"
android:textStyle="bold" />
<TextView
android:id="#+id/Clugar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Ctitle"
android:layout_alignStart="#+id/Ctitle"
android:layout_below="#+id/Ctitle"
android:layout_marginTop="10dp"
android:text="Lugar" />
<TextView
android:id="#+id/textView29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Clugar"
android:layout_alignStart="#+id/Clugar"
android:layout_below="#+id/Clugar"
android:layout_marginTop="10dp"
android:text="$" />
<TextView
android:id="#+id/Cprice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/textView29"
android:layout_marginBottom="4dp"
android:layout_toEndOf="#+id/textView29"
android:layout_toRightOf="#+id/textView29"
android:paddingLeft="5dp"
android:text="0.0" />
<TextView
android:id="#+id/Cdur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/Clugar"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="126dp"
android:layout_marginRight="126dp"
android:text="Duración" />
<TextView
android:id="#+id/Cnivel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/Cprice"
android:layout_alignLeft="#+id/Cdur"
android:layout_alignStart="#+id/Cdur"
android:layout_marginBottom="0dp"
android:text="Nivel" />
</RelativeLayout>
</LinearLayout> </android.support.v7.widget.CardView>
This is the mView:
public static class CursosPViewHolder extends RecyclerView.ViewHolder {
View mView;
public CursosPViewHolder(final View itemView) {
super(itemView);
mView = itemView;
}
public void setTitle(String title){
TextView post_title = (TextView)mView.findViewById(R.id.Ctitle);
post_title.setText(title);
}
public void setCiudad (String ciudad){
TextView post_city = (TextView)mView.findViewById(R.id.Clugar);
post_city.setText(ciudad);
}
public void setPhotoURL(Context ctx, String pgotouserurl) {
ImageView post_image =(ImageView)mView.findViewById(R.id.Cimg);
Picasso.with(ctx).load(pgotouserurl).into(post_image);
} }
I hope you can help me.
First the XML code you've posted ils wrong closed,(must finish with a CardView tag)
On addition be sure you're pointing the CardView layout with mView field ans Only use GONE or INVISIBLE,
INVISIBLE change your Panel ( Root view ) structure but GONE don't

Categories

Resources