gabrielemariotti / cardslib Goto Github PK
View Code? Open in Web Editor NEWAndroid Library to build a UI Card
Android Library to build a UI Card
When I try to install demo040.apk
The system give me this error:
There was a problem parsing the package
Hi, I'm trying to find a way to toggle the expanding of the card from the header's card_header_button_expand ImageButton to Card.setOnClickListener.
I have managed to make it work like this:
//Set visible the expand/collapse button
header.setButtonExpandVisible(true);
//Add Header to card
card.addCardHeader(header);
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
ImageButton expandButton = (ImageButton) view.findViewById(R.id.card_header_button_expand);
expandButton.callOnClick();
}
});
However doing it this way:
Is there a more elegant way to achieve this?
I was trying to implement this but everytime I've clicked the button to expand I got this error
11-06 16:10:05.210: E/AndroidRuntime(646): FATAL EXCEPTION: main
11-06 16:10:05.210: E/AndroidRuntime(646): java.lang.NoSuchMethodError: android.view.View.setHasTransientState
11-06 16:10:05.210: E/AndroidRuntime(646): at it.gmariotti.cardslib.library.view.CardListView$1.onPreDraw(CardListView.java:323)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1596)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2418)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.os.Handler.dispatchMessage(Handler.java:99)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.os.Looper.loop(Looper.java:137)
11-06 16:10:05.210: E/AndroidRuntime(646): at android.app.ActivityThread.main(ActivityThread.java:4340)
11-06 16:10:05.210: E/AndroidRuntime(646): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 16:10:05.210: E/AndroidRuntime(646): at java.lang.reflect.Method.invoke(Method.java:511)
11-06 16:10:05.210: E/AndroidRuntime(646): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-06 16:10:05.210: E/AndroidRuntime(646): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-06 16:10:05.210: E/AndroidRuntime(646): at dalvik.system.NativeStart.main(Native Method)
I though i was doing something wrong but I've just tested the demo and it crashes too
I'm using the latest android studio, I have included this line:
compile 'com.github.gabrielemariotti.cards:library:0.9.0' in dependencies
My minSdkVersion is set to 14 , the project builds perfectly fine, but it doesn't look like the library is been referenced, are there any additional steps required to make this work?
I'm creating a StateListDrawable dynamically, and want to set it as the background of my card (like you would do with setBackgroundResourceId(int id), but directly with a Drawable or a selector.
I'm looking for a method looking like this: setBackgroundResource(StateListDrawable s) or setBackgroundResource(Drawable d)... or is there any other way of doing it?
PS: I also can't seem to find how to set a max height for the cards.
add the possibility to placing the thumbnail in another position in the parent card (top, right, ...)
Thank you
I'm having weird animations using CardExpand, i first though it was a compatibility issues with other libraries so i created a simple project just using CardsLib and the problem persists, it happens when the expand card is collapsed after the expand.
Here is the code and the test apk https://github.com/BradleyRL/TestCardsLib
Evaluating project ':library' using build file '/Users/kuzhu/Android/Demo/cardslib-master/library/build.gradle'.
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/18.0.0/support-v4-18.0.0.pom]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar]
FAILURE: Build failed with an exception.
Where:
Build file '/Users/kuzhu/Android/Demo/cardslib-master/build.gradle' line: 25
What went wrong:
A problem occurred evaluating root project 'cardslib-master'.
A problem occurred configuring project ':demo'.
Failed to notify project evaluation listener.
Could not resolve all dependencies for configuration ':demo:_DebugCompile'.
> Could not find com.android.support:support-v4:18.0.0.
Required by:
com.github.gabrielemariotti.cards:demo:0.5.1-SNAPSHOT
After the changing the api level 16 or higher , I was able to get it to work
The short version:
When the OnClickListener or OnLongClickListener is set for a Card, it consumes all TouchEvents.
The long version:
I am trying to enable Pull-to-Refresh on a CardListView --
https://github.com/chrisbanes/ActionBar-PullToRefresh
The CardListView needs to handle Swipes. But when either the OnClickListener or OnLongClickListener is set on the Cards, the TouchEvents get intercepted. I suspect it is because when either of the listeners are set, Card.IsEnabled() returns true. And when Card.IsEnabled() returns true, the Cards handle all TouchEvents.
I would expect this behavior if the Card were both Enabled and set as Swipeable, but not if Swipeable is set to False.
From an email:
shadow is still linear and doesnt stop before the corner begins.
Adding a margin fix it.
<!-- Shadow @Modification by Marcel-->
<dimen name="card_shadow_height">3dp</dimen>
<dimen name="card_shadow_view_margin_top">0dp</dimen>
<dimen name="card_shadow_view_margin_left">@dimen/card_background_default_radius</dimen>
<dimen name="card_shadow_view_margin_bottom">0dp</dimen>
<dimen name="card_shadow_view_margin_right">@dimen/card_background_default_radius</dimen>
First of all Thanks for the awesome library.
when i click the card by using the below code the card state is not changing as per the card_selector
Create a Card
Card card = new CustomCard(getActivity());
//Set onClick listener
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(),"Clickable card", Toast.LENGTH_LONG).show();
}
});
how to change the state of color when clicked.
If possible add an ability to use StickyListHeaders or Indexable List View to CardList or CardGrid.
You can also get help from here
https://github.com/emilsjolander/StickyListHeaders
I try to implement infinite scroll.
But when setOnScrollListener it fires some tines a stop, not firing any more.
I test with standard ListView and work well:
Binding:
listView.setOnScrollListener(
new AbsListView.OnScrollListener() {
@OverRide
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//what is the bottom iten that is visible
int lastInScreen = firstVisibleItem + visibleItemCount;
Debug.Log(TAG, "lastInScreen." + lastInScreen);
}
});
///
Adapter:
public class NewsCardAdapter extends CardArrayAdapter{
private int lastPosition = -1;
private List mcards;
/**
* Constructor
*
* @param context The current context.
* @param cards The cards to represent in the ListView.
*/
public NewsCardAdapter(Context context, List<Card> cards) {
super(context, cards);
mcards = cards;
}
@Override
public int getCount() {
Debug.Log(TAG, "Adapter.getCount." + mcards.size());
return mcards.size();
}
@Override
public Card getItem(int position) {
Debug.Log(TAG, "Adapter.getItem");
return mcards.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
return view;
}
@Override
public int getViewTypeCount() {
return 3;
}
}
Hi,
I'm currently trying to undo the removing of cards like it is in your example "List with undo". I've implemented the exact same source code but it's not working and after a short view into the sourcecode I'm not seeing any line where you add the view back to the layout. Where do you do this and how can I achieve this? Furthermore your UndoController is never initialized.
I tried to add the following lines to the onUndoSwipe-method:
mCardArrayAdapter.add(card);
mCardArrayAdapter.notifyDataSetChanged();
but nothing happens either....
Additional question: How is it possible to modify the onSwipe-Gesture? I'd like to set the visibility to hidden instead of removing the card and remove the card after the undo button is disappeared. Then I can easily animate the "undo" function -> swipe it in again.
Thanks
Closed: nevermind... forgot to set the id
I've slightely changed the expanded-card style (it now contains the custom inner style of your example application). When I expand the card, everything works fine. When I now scroll the item out of view and then scroll back, the text in the expanded card doesn't fit anymore into the view. It's now displayed in one single line.
(Edit: Code removed - not necessary here)
Here are three pictures of the behaviour:
Edit: This seems to be an issue of the library - you can see the same behaviour in your demo-application.
Additionally, when I remove an expanded card, the other cards don't use the removed space of the expanded card, seen here:
Did I do something wrong or is this a bug in your version?
Edit: Two more questions about the expanded card: How can I let the card expand without clicking the expand-button?
And how can I add an onclick-listener to the expanded card?
Merry Christmas!
Hi Gab, further to my G+ post, I've narrowed down the problem:
This is how I'm declaring my CardListView
<it.gmariotti.cardslib.library.view.CardListView
android:id="@+id/lvSources"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relSourcesTitle"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card:list_card_layout_resourceID="@layout/list_card_sources_layout" />
This is my CardView it refers to:
<it.gmariotti.cardslib.library.view.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:id="@+id/list_cardId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/sources_list_card.base"
card:card_layout_resourceID="@layout/card_sources_list_layout"/>
Then I have the custom inner layout in card_sources_list_layout
^ It doesn't work.
If I change the declaration and my layout name to:
card:list_card_layout_resourceID="@layout/list_card_layout"
It calls correctly:
@Override
public void setupInnerViewElements(....)
But the style is of the default Library.
Am I missing something with how to declare, name and correctly apply the custom elements?
Thanks in advance!
Ben
das
java.lang.NullPointerException
at it.gmariotti.cardslib.demo.fragment.StockCardFragment.getShareIntent(StockCardFragment.java:105)
at it.gmariotti.cardslib.demo.fragment.StockCardFragment.onCreateOptionsMenu(StockCardFragment.java:76)
at android.app.FragmentManagerImpl.dispatchCreateOptionsMenu(FragmentManager.java:1871)
Loving this library. Thanks so much.
I'm having a little trouble using my own list_card_layout. Substituting my own xml layout (with a FrameLayout as the base) leads to problems with layout params in the library. Switching back to CardView as the base (and only element in the xml file) fixes the problem. I tried to debug it myself but I can't figure out exactly what's going on. Am I doing something wrong?
FYI: the problem only manifests itself when collapsing an expanded card in a list. Thanks for any help you can provide.
12-02 16:20:27.043: E/AndroidRuntime(10369): FATAL EXCEPTION: main
12-02 16:20:27.043: E/AndroidRuntime(10369): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.AbsListView$RecycleBin.fillActiveViews(AbsListView.java:6502)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.ListView.layoutChildren(ListView.java:1562)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.AbsListView.onLayout(AbsListView.java:2237)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.onLayout(CustomViewAbove.java:476)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.View.layout(View.java:13840)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewGroup.layout(ViewGroup.java:4372)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1948)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1758)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1042)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4329)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.Choreographer.doFrame(Choreographer.java:525)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.os.Handler.handleCallback(Handler.java:615)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.os.Looper.loop(Looper.java:137)
12-02 16:20:27.043: E/AndroidRuntime(10369): at android.app.ActivityThread.main(ActivityThread.java:5059)
12-02 16:20:27.043: E/AndroidRuntime(10369): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 16:20:27.043: E/AndroidRuntime(10369): at java.lang.reflect.Method.invoke(Method.java:511)
12-02 16:20:27.043: E/AndroidRuntime(10369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
12-02 16:20:27.043: E/AndroidRuntime(10369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
12-02 16:20:27.043: E/AndroidRuntime(10369): at dalvik.system.NativeStart.main(Native Method)
12-02 16:20:28.277: I/Process(10369): Sending signal. PID: 10369 SIG: 9
12-02 16:21:30.433: E/Trace(10458): error opening trace file: No such file or directory (2)
I using a Light and Dark themes on my application also using the Expand Cards, but when im using a Dark Theme the ic_menu_expand_card_dark_normal is really hard to see, so i tried to use an attr in order to change the icon according to the theme
First I copied card_menu_button_expand.xml to my project and modified it like this
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_menu_expand_card_dark_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/ic_menu_expand_card_dark_pressed"
android:state_focused="true"/>
<item android:drawable="@drawable/ic_menu_expand_card_dark_pressed"
android:state_selected="true"/>
<item android:drawable="?attr/info_icon"/>
my attrs.xml
<resources>
<attr name="info_icon" format="reference"/>
</resources>
and my themes.xml
<style name="DarkTheme" parent="@android:style/Theme.Holo">
<item name="info_icon" >@drawable/ic_menu_expand_card_light_normal"</item>
</style>
<style name="LightTheme" parent="@android:style/Theme.Holo.Light">
<item name="info_icon" >@drawable/ic_menu_expand_card_dark_normal"</item>
</style>
But im getting a Force Close
12-02 14:43:23.650: E/AndroidRuntime(4555): FATAL EXCEPTION: main
12-02 14:43:23.650: E/AndroidRuntime(4555): android.view.InflateException: Binary XML file line #23: Error inflating class it.gmariotti.cardslib.library.view.CardView
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-02 14:43:23.650: E/AndroidRuntime(4555): at it.gmariotti.cardslib.library.internal.CardArrayAdapter.getView(CardArrayAdapter.java:142)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.AbsListView.obtainView(AbsListView.java:2033)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.ListView.makeAndAddView(ListView.java:1772)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.ListView.fillDown(ListView.java:672)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.ListView.fillFromTop(ListView.java:732)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.ListView.layoutChildren(ListView.java:1625)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.widget.AbsListView.onLayout(AbsListView.java:1863)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.View.layout(View.java:11180)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.ViewGroup.layout(ViewGroup.java:4203)
12-02 14:43:23.650: E/AndroidRuntime(4555): Caused by: android.view.InflateException: Binary XML file line #40: Error inflating class it.gmariotti.cardslib.library.view.component.CardHeaderView
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-02 14:43:23.650: E/AndroidRuntime(4555): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-02 14:43:23.650: E/AndroidRuntime(4555): at it.gmariotti.cardslib.library.view.BaseCardView.initView(BaseCardView.java:153)
12-02 14:43:23.650: E/AndroidRuntime(4555): at it.gmariotti.cardslib.library.view.BaseCardView.init(BaseCardView.java:125)
12-02 14:43:23.650: E/AndroidRuntime(4555): at it.gmariotti.cardslib.library.view.BaseCardView.(BaseCardView.java:101)
12-02 14:43:23.650: E/AndroidRuntime(4555): at it.gmariotti.cardslib.library.view.CardView.(CardVi
Any input of what I'm doing wrong would be great or the lib doesn't support these?
Hi,
I have a drawable resource file to set rounded corners.
drawable/bg_thumbnail
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="20dip" />
</shape>
I tried setting android:background="@drawable/bg_thumbnail"
and <item name="android:background">@drawable/bg_thumbnail</item>
in several places like
<style name="card_thumbnail_image">
and <style name="card_thumbnail_outer_layout">
Thank you.
I made a simple activity, but the image (thumbnail) is not showing, Please help me, what is the problem.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Card card = new Card(getApplicationContext());
CardThumbnail thumb = new CardThumbnail(getApplicationContext());
// Set resource
thumb.setDrawableResource(R.drawable.ic_launcher);
// Add thumbnail to a card
card.addCardThumbnail(thumb);
CardView cardView = (CardView) findViewById(R.id.carddemo);
cardView.setCard(card);
}
Hi Gabriele,
I'm trying to customize a Card in a CardListView but I'm having a problem with card:list_card_layout_resourceID, that's this attribute, despite of the others like card:card_layout_resourceID, not working to reference with another layout.
I followed the example in the docs...
Thanks for your help.
Merry Christmas :)
I have created a CardListView. I add a card type in particular first (name it MyCardA) and then several (in my case 7) cards of a different type (e.g. MyCardB). Initially it works fine, but when I scroll down the list, suddenly the Card List tries to setup the inner elements of a MyCardB card but including a MyCardA's view as parameter of the setupInnerViewElements method, instead of a MyCardB's view. As a result, a NullPointerException is thrown because the view elements of the card contents are not found.
So, summarizing, adding different types of card in a CardListView seems to be unreliable.
Why is it that the minimum SDK version is 14?
Is their any way that your library can be use in lower SDK? maybe 11? or 12?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cdasiaonline-android:processDefaultFlavorDebugManifest'.
> Manifest merging failed. See console for more info.
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:230)
at android.content.res.Resources.getString(Resources.java:314)
at android.content.Context.getString(Context.java:327)
at it.gmariotti.cardslib.demo.MainActivity$CustomActionBarDrawerToggle.onDrawerClosed(MainActivity.java:232
Hi,
I am having trouble when trying to define gravity for Header. As you can see from the screenshot, the header is not vertically centered. I tried to put android:layout_gravity="center_vertical" to it.gmariotti.cardslib.library.view.component.CardHeaderView in layout/card_thumbnail_layout but the header text is still not vertically centered.
Am I editing the wrong file?
Now I'm trying to run Demo App with Android Studio. Unfortunately I'm reaching 3 error:
I have imported the Demo code and I have modified the build.gradle from "compile project(':library')" to "compile 'com.github.gabrielemariotti.cards:library:1.1.0'".
I have a list of custom cards but I need to add a header and a custom expandcard to them but I'm getting a NPE when I click on the icon.
This is the way I'm doing it
ArrayList<Card> cards = new ArrayList<Card>();
for (int i=0;i<3;i++){
//Create a Card
NewCardSwitch card = new NewCardSwitch(getActivity().getApplicationContext());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity().getApplicationContext());
//Set the header title
header.setTitle("title "+i);
//Set visible the expand/collapse button
header.setButtonExpandVisible(true);
//Add Header to card
card.addCardHeader(header);
//This provides a simple (and useless) expand area
InfoExpandCard expand = new InfoExpandCard(getActivity().getApplicationContext());
//Add Expand Area to CardC
card.addCardExpand(expand);
cards.add(card);
}
If I don't use a custom card everything works, what am i missing here?
public class NewCardSwitch extends Card{
public NewCardSwitch(Context context) {
this(context, R.layout.new_card_switch);
}
public NewCardSwitch(Context context, int innerLayout) {
super(context, innerLayout);
init(context);
}
private void init(Context context){
}
@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
}
}
This is my custom card nothing out of the extraordinary just layout with a switch in it
Also what the proper way of having a list with cards with different heights i cant figure that out?
Hi,
I'm using this library alot & love the customisation & capabilities of this library.
No doubt that Cards look awesome in Holo Light Theme but is there any possibility to implement an method to switch to Holo Dark Theme.
Thanks in advance.
Hello,
I have found a nice card appearance here: http://ryanharter.com/blog/2013/01/31/how-to-make-an-android-card-list/
Even I prefer the look of that one but I still want to use functionality of this library. Can I customize the card accordingly?
Thank you.
Hi!
I am very interesting in your library and its help me so much in designing android application.
I see your demo here: https://play.google.com/store/apps/details?id=it.gmariotti.cardslib.demo
Can you provide full source code of this sample. (Maybe many developer need its as me)
Thank for your great job
The API for GridViews doesn't include footer views. It would be nice to have a "Show more cards..." button (Like Google Now) or a loading progressbar when the user scrolls to the bottom. Is there a good alternative for this?
This library is very much not easy to use as it required very specific software.
It is not a standard android library and it requires a specific version of grade to build, even if you can get it to compile.
Consider giving the project a structure that makes it easy to integration into a basic Android application.
I am having problems viewing the demo after importing it into Eclipse. There are three errors in the styles.xml and I am not sure how to fix them. They are as follows:
Thanks for making this awesome library.
CardThumbnail currently supports only setDrawable where the resource id of id is passed.
But, Bitmap or Drawable are also needed for some advance image working.
I hope you add an method for setting an bitmap image.
Can the library change so that it could use Adapter?
Log
:cdasiaonline-android:dexDefaultFlavorDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lit/gmariotti/cardslib/library/Constants$IntentManager;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
FAILED
settings.gradle
include ':cardslib:library'
project(':cardslib:library').projectDir = new File(settingsDir, 'cardslib/library')
compile project(path: ':cardslib:library')
I'm currently have the issue that the header-view of my cards are overlapping with the expand/menu icons.
You can see this behaviour here:
I think the problem is in the base_header_layout where the button_frame and the card_header_inner_frame are both framelayouts and there is no restriction about overlapping (and there shouldn't of course)
How can I solve this behaviour? I'd guess I have to add a margin to the card_header_inner_frame - but where?
Thanks
Hi,
I am using this cardslib and it's amazing. However, I am facing a problem that after I fetched some content (using AsyncTask::onPostExecute) and add cards to a cardslist array, the CardListView won't update the content. That's said the cards I created after AsyncTask::onPostExecute won't be shown.
Is there anyway to force CardListView to reload cards so I can display newly fetched content.
Thank you.
I believe API 14 was just released to Nexus and quickly updated to 15 such that 14 doesn't exit any more.
So, not that it matters much either way, but I don't think there is much point in supporting 14 and you'd be hard pressed to actually test on an API 14 device.
Thanks for this great library. I feel the biggest thing missing is a drag and drop feature to go with the swipe and undo features.
Are there any plans to create a CardCursorAdapter or something to that effect that you can use cursor with? Right now the only way I can use stuff from my database is to pull the what I want then loop through my cursor and create a ArrayList of cards which seems inefficient since it has to loop through the array list again to get the information from the list to display when I already got it from the cursor
I'm having some trouble and i think its caused because whenever I scroll on the view the method setupInnerViewElements get called again everytime for every card
My example is I have a bunch of cards with seekbars and a textview to show the value of it, when i create the cards Ive send them the max and initial progress for it and it displays ok, but when i start scrolling the texview start showing random values without a seekbar change.
Any reason of why are you calling setupInnerViewElements when you scroll through the view everytime ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.