{"id":560,"date":"2014-10-18T14:44:27","date_gmt":"2014-10-18T12:44:27","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=560"},"modified":"2014-10-18T14:44:27","modified_gmt":"2014-10-18T12:44:27","slug":"android-swipe-to-reveal","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2014\/10\/18\/android-swipe-to-reveal\/","title":{"rendered":"Android swipe to reveal"},"content":{"rendered":"<p>More and more Android apps seem to use a <a href=\"http:\/\/unitid.nl\/androidpatterns\/uap_pattern\/swipe-for-action\" target=\"_blank\">swipe-to-reveal or swipe-for-action<\/a> UX pattern with <a href=\"http:\/\/developer.android.com\/guide\/topics\/ui\/layout\/listview.html\" target=\"_blank\">ListViews<\/a>. This is a nice way to give (power) users fast access to certain actions. One of the downsides is that these swipe gestures are often hard to discover.<\/p>\n<p>If you want to use this technique, have a look at 47 degree&#8217;s\u00a0<a href=\"https:\/\/github.com\/47deg\/android-swipelistview\" target=\"_blank\">android-swipelistview<\/a> library.<\/p>\n<p>I ran into a small issue when trying it out. When I was building my project, I got the following error:<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">bash<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"bash\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">error: Attribute <span style=\"color: #ff0000\">&quot;***&quot;<\/span> has already been defined<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>In my case this was caused by <a href=\"http:\/\/actionbarsherlock.com\/\" target=\"_blank\">ActionBarSherlock<\/a> using the same library as the android-swipelistview project. Adding an exclusion to my Gradle build script solved this.<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">groovy<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"groovy\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">compile <span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #ff0000\">'com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar'<\/span><span style=\"color: #66cc66\">&#041;<\/span> <span style=\"color: #66cc66\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; transitive <span style=\"color: #66cc66\">=<\/span> <span style=\"color: #000000;font-weight: bold\">true<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; exclude group: <span style=\"color: #ff0000\">&quot;com.android.support&quot;<\/span>, module: <span style=\"color: #ff0000\">&quot;appcompat-v7&quot;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #66cc66\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p><strong>Usage in combination with\u00a0SwipeRefreshLayout<\/strong><\/p>\n<p>If you want this swipe library in combination with the new\u00a0<a href=\"http:\/\/developer.android.com\/reference\/android\/support\/v4\/widget\/SwipeRefreshLayout.html\" target=\"_blank\">SwipeRefreshLayout<\/a> class, there is a little more work you need to do. To facilitate this, I have <a href=\"https:\/\/github.com\/wjwarren\/android-swipelistview\" target=\"_blank\">forked<\/a> the original project and added the functionality as suggested by\u00a0<a href=\"https:\/\/github.com\/keiththompson\" target=\"_blank\">Keith Thompson<\/a> in the <a href=\"https:\/\/github.com\/47deg\/android-swipelistview\/issues\/139\" target=\"_blank\">issue<\/a> he opened on the project site.<\/p>\n<p>I ran into another issue where both the swipe-to-reveal as the pull-to-refresh actions were performed. This would happen when the ListView was at the top, the user would\u00a0swipe horizontally and then pulled down. This has been fixed in my fork too.<\/p>\n<p>An example of how to hook up this functionality can be found in <a href=\"https:\/\/github.com\/keiththompson\/SwipeListViewRefresh\/tree\/master\" target=\"_blank\">Keith&#8217;s fork<\/a> of the android-swipelistview\u00a0project.\u00a0The key classes to look at are &#8220;CustomSwipeRefreshLayout&#8221; in the sample project and &#8220;RefreshSwipeListView&#8221; in the library.<\/p>\n<p><strong>Other issues<\/strong><\/p>\n<p>The original\u00a0android-swipelistview\u00a0project has some other issues too:<\/p>\n<ul>\n<li>When ListView items are clickable, the item would <a href=\"https:\/\/github.com\/47deg\/android-swipelistview\/issues\/76\" target=\"_blank\">no longer be clickable after swiping once<\/a>.<\/li>\n<li>Another problem with clickable items is that sometimes they would<a href=\"https:\/\/github.com\/47deg\/android-swipelistview\/issues\/41#issuecomment-22960261\" target=\"_blank\"> stay in the pressed state<\/a>.<\/li>\n<\/ul>\n<p>The fixes for these issues have been committed to <a href=\"https:\/\/github.com\/wjwarren\/android-swipelistview\" target=\"_blank\">my fork of\u00a0android-swipelistview<\/a> too.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>More and more Android apps seem to use a swipe-to-reveal or swipe-for-action UX pattern with ListViews. This is a nice way to give (power) users fast access to certain actions. One of the downsides is that these swipe gestures are &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2014\/10\/18\/android-swipe-to-reveal\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112,52],"tags":[],"class_list":["post-560","post","type-post","status-publish","format-standard","hentry","category-android","category-java"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=560"}],"version-history":[{"count":8,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/560\/revisions"}],"predecessor-version":[{"id":568,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/560\/revisions\/568"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}