Comments (11)
I'm afraid that's not enough information for me to figure out what the problem is. Can you share the code (layout and related java source)?
Have you tried following the demo example?
https://github.com/cachapa/ExpandableLayout/blob/master/demo/src/main/java/net/cachapa/expandablelayoutdemo/RecyclerViewFragment.java
from expandablelayout.
Ok!
This is my Adapter class:
package br.com.medflex.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageButton;
import android.widget.TextView;
import net.cachapa.expandablelayout.ExpandableLayout;
import java.util.List;
import br.com.medflex.R;
import br.com.medflex.utils.MinhaConsulta;
public class MinhaConsultaAdapter extends RecyclerView.Adapter<MinhaConsultaAdapter.ViewHolder> {
private int UNSELECTED = -1;
private RecyclerView recyclerView;
private int selectedItem = UNSELECTED;
private List<MinhaConsulta> consultas;
public MinhaConsultaAdapter(RecyclerView recyclerView, List<MinhaConsulta> consultas) {
this.recyclerView = recyclerView;
this.consultas = consultas;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.expandable_minha_consulta_row, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return consultas.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private ExpandableLayout expandableLayout;
private TextView especialidade, data, hora, local;
private ImageButton imgExpand;
private int position;
public ViewHolder(View itemView) {
super(itemView);
expandableLayout = (ExpandableLayout) itemView.findViewById(R.id.expandable_recycler);
expandableLayout.setInterpolator(new OvershootInterpolator());
especialidade = (TextView) itemView.findViewById(R.id.txt_consulta_especialidade);
data = (TextView) itemView.findViewById(R.id.txt_consulta_data);
especialidade.setOnClickListener(this);
}
public void bind(int position) {
this.position = position;
especialidade.setSelected(false);
expandableLayout.collapse(false);
especialidade.setText(consultas.get(position).getEspecialidade());
data.setText(consultas.get(position).getData());
}
@Override
public void onClick(View v) {
ViewHolder viewHolder = (ViewHolder) recyclerView.findViewHolderForAdapterPosition(selectedItem);
if (viewHolder != null) {
viewHolder.imgExpand.setSelected(false);
viewHolder.expandableLayout.collapse();
}
if (position == selectedItem) {
selectedItem = UNSELECTED;
} else {
imgExpand.setSelected(true);
expandableLayout.expand();
selectedItem = position;
}
}
}
}
```
And that's my layout file:
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txt_consulta_especialidade"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="6dp"
android:foreground="?selectableItemBackground"
android:padding="@dimen/activity_horizontal_margin"
android:text="Especialidade 01" />
<net.cachapa.expandablelayout.ExpandableLayout
android:id="@+id/expandable_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/img_expandable"
app:el_duration="300"
app:el_expanded="false">
<TextView
android:id="@+id/txt_consulta_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data" />
</net.cachapa.expandablelayout.ExpandableLayout>
</LinearLayout>
```
from expandablelayout.
Your layout file is incomplete.
Please post the exact code, otherwise it's almost impossible to figure out where the problem is.
from expandablelayout.
It was an edition error. Sorry about it. Updated!
from expandablelayout.
Sorry I couldn't replicate the issue.
Would it be possible to share a small project with the problem?
from expandablelayout.
Yep, i'll share with you soon.
from expandablelayout.
Check it out: https://github.com/joaovictortinoco/mobix-medflex-android/tree/medflex-v1
from expandablelayout.
I actually was looking for a small project that just shows the problem. I couldn't even find the screen where you use the recyclerview.
from expandablelayout.
Sorry man, the project is huge.
Look again, please.
You should look for the references in fragment folder, "MinhaConsultaFragment.java" that points to the layout. And if you run the application, the error log will be the first.
from expandablelayout.
Sorry but I don't have the time to dig through so much code.
The use case you mention works fine in the demo project, which you seem to have copied.
If you can't produce a compact example that shows the problem I'll have to assume the issue lies in your changes and close this report.
from expandablelayout.
Ok, then. Thanks anyway.
from expandablelayout.
Related Issues (20)
- Expandable Layout not working in coordinator layout, But working smoothly in linear layout HOT 6
- 3 fill parent Accordion menus HOT 7
- Resetting child view when expanding other view HOT 4
- At a time one expand HOT 2
- Can I expand multiple views at the same time? HOT 3
- Request: Linear layout as root. HOT 3
- Scroll RecyclerView to show selected item expand on top HOT 1
- Indication Markers HOT 1
- Starting expanded HOT 1
- Start expanded HOT 1
- Move away from JCenter HOT 1
- library wont expand on androidx.constraintlayout:constraintlayout:2.0.4 HOT 1
- JCenter is scheduled for closing HOT 1
- mavenCentral() support HOT 1
- mavenCentral() support HOT 1
- Toggle with out clicking on expandable view
- toped working after went to MavenCentral() HOT 2
- How can expand the fist group programatically? HOT 1
- Scrolling to item position is not working
- Unable to download dependency from Maven HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandablelayout.