0
And I want to take dynamic data to show on the screen. Dynamic data that will come from a webservice.
So I need to use Recyclerview with Cardview Layout to make the data dynamic?
How can I make my Cardview as if it were elements of a Listview?
0
And I want to take dynamic data to show on the screen. Dynamic data that will come from a webservice.
So I need to use Recyclerview with Cardview Layout to make the data dynamic?
How can I make my Cardview as if it were elements of a Listview?
2
First, after the project is created, go to the file build.gradle (app)
and add the following dependencies:
compile ‘com.android.support:cardview-v7:21.0.+’
compile ‘com.android.support:recyclerview-v7:21.0.+’
Then in your list there is an item, which is probably set in your Adapter. The following code example shows how to include a widget CardView
in the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
... >
<!-- Um CardView com um TextView dentro -->
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.CardView>
</LinearLayout>
See more details in the documentation on how to create lists and cards.
Browser other questions tagged java android
You are not signed in. Login or sign up in order to post.
Hi Ack, so when you refer to the list you meant to Listview or recyclerview?
– Aline
Which one you want of the two, which you are currently using. To better adapt to your scenario, it would be good for you to add your code.
– viana
I think I understand... I have a listview and each element of the list I am directed to a screen and from there I can make some modification...I wish my Listview had the style of Cardview...
– Aline
I have a layout that has two textView and these elemesos are shown on each element of the list... and I inflate with the layout of the listview
– Aline
I’ll modify it and show it here...
– Aline
@Aline It’s easy! Each item in your project has a layout. Each person puts the name you think best, example:
row.xml
,item.xml
,meu_item.xlm
,item_list.xml
. This same layout that has textView will change and put the cardview. There you insert the two Textview inside the cardView and kill the riddle.– viana
That’s when I thought
– Aline
Wait I need to put xmlns:card_view="http://schemas.android.com/apk/res-auto" in all my Linear layout besides cardView? Because I have a textview that sits within two Linearlayout
– Aline
@Aline See the change.
– viana
@Aline leaving only in Linearlayout, already solves the problem
– viana
It did not work no. I needed to show 10 items from a list, only that appeared only 8 elements.
– Aline
@Aline the problem there is no longer Cardview understand?! This answer meets very well what you want. So I suggest asking another question, to know why you are not listing these 10 items. You pull from where these items. If you are really going to ask another question, try to detail your problem better by inserting part of your code.
– viana
I fixed it. Thanks it all worked out!
– Aline
@Aline =) That’s it ae! o/
– viana