可穿戴支持库1.1中缺少WearableListView.Item

时间:2014-12-12 12:00:41

标签: android wear-os

我的穿戴应用程序使用WearableListView.Item作为ListView,它运行良好并编译 - 但随后我升级了Android Studio,Gradle插件,SDK工具等等,现在它不会编译。

我的穿着build.gradle包含:

compileSdkVersion 20
buildToolsVersion "21.1.2"
...
    minSdkVersion 20
    targetSdkVersion 20
...

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile 'com.google.android.support:wearable:+'
   compile 'com.google.android.gms:play-services-wearable:6.5.+'
}

现在它说:错误:(141,84)错误:找不到符号类Item

请帮忙吗?

4 个答案:

答案 0 :(得分:5)

那是因为API已经改变了。它现在取决于RecyclerView

Here is a gist展示了如何实施WearableListView

答案 1 :(得分:2)

这里是WearableListView的一个很好的实现,使用可穿戴支持库的v1.1.0,它仍然支持正确的缩放行为(直接来自Google官方样本):

android-WatchFace/DigitalWatchFaceWearableConfigActivity.java

答案 2 :(得分:0)

看起来像(source)要解决此问题,您需要更改:

compile 'com.google.android.support:wearable:+'

compile 'com.google.android.support:wearable:1.0.0'

在适当的修复程序出现之前,这只是一个临时的解决方法。

答案 3 :(得分:0)

现在,你应该这样做:

<html>

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.min.css" type="text/css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.concat.min.js"></script>
  <script src="https://raw.githubusercontent.com/iominh/ng-scrollbars/master/src/scrollbars.js"></script>
  <script>
    var app = angular.module('app', ['ngScrollbars']);
    app.config(function(ScrollBarsProvider) {
      // scrollbar defaults
      ScrollBarsProvider.defaults = {
        autoHideScrollbar: false,
        setHeight: 100,
        scrollInertia: 0,
        axis: 'yx',
        advanced: {
          updateOnContentResize: true
        },
        scrollButtons: {
          scrollAmount: 'auto', // scroll amount when button pressed
          enable: true // enable scrolling buttons by default
        }
      };
    });

    function MainController($scope) {
      // example of overriding defaults per scrollbar
      $scope.scrollbarConfig = {
        theme: 'dark',
        scrollInertia: 500
      }
    }

    app.controller('mainCtrl', MainController);
  </script>
</head>

<body ng-app="app" ng-controller="mainCtrl">

  <div style="width: 200px;" ng-scrollbars ng-scrollbars-config="scrollbarConfig">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ornare magna ultrices tincidunt tincidunt. Donec sagittis lorem placerat iaculis vehicula. Nunc bibendum quam vel rutrum rutrum. Duis nunc dolor, vehicula vitae pulvinar eu, semper vitae eros.
    Proin auctor, felis placerat posuere dictum, massa ipsum fermentum ipsum, sit amet tincidunt metus justo ut dui. Curabitur aliquet tempor dolor eget volutpat. Proin consequat metus id justo interdum, id porta justo venenatis. Nullam vel tristique
    neque, at luctus velit. Nulla sit amet convallis felis.
  </div>

</body>

</html>

或者:

public class ItemView extends FrameLayout implements WearableListView.OnCenterProximityListener

因为WearableListView.Item接口不适用更多。 我希望能帮到你。