表情猜人名海螺游泳大号🐚&#1279年46;&#1279年27;

最近使用Android Studio开发一个新项目,刚做完几个界面,跑在android 5.0上面很正常,因为都是挺简单的布局,本以为应该不存在兼容性问题(Flag啊)。偶然用了一个4.x的实机测试,发现杯具了,直接报错退出了,发现log里面打出这么一句:java.lang.UnsupportedOperationException: Can't convert to color: type=0x2难以理解啊,没办法一步一步调试吧。顺便说一下调试要注意的问题,如果compileSdkVersion与实际出错的android版本不符合,是没法设置断点的。改为一致之后,一步一步看,最后发现问题出在一个drawable xml文件上,之前是这么写的:&?xml version=&1.0& encoding=&utf-8&?&&shape xmlns:android=&/apk/res/android&android:shape=&rectangle&&&strokeandroid:width=&0.5dp&android:color=&?colorPrimary& /&&/shape&也是摸不着头脑,很正常啊。尝试一下吧?colorPrimary改成直接的color引用试一试吧。&?xml version=&1.0& encoding=&utf-8&?&&shape xmlns:android=&/apk/res/android&android:shape=&rectangle&&&strokeandroid:width=&0.5dp&android:color=&@color/carnation& /&&/shape&一运行,果然成功了。看起来像是android4.x系统上因为某种原因,无法在drawable xml文件里面使用attr属性,5.x上没有这个问题。希望对遇到类似can't convert xxx type=0x00问题的朋友有所启发和帮助。如果有人能够告诉我具体原因,我也会十分感谢(果然android兼容是个大坑啊!
无相关信息마누라怎么读_百度知道
마누라怎么读
我有更好的答案
마누라读作manula意思妻
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁동두천怎么读_百度知道
동두천怎么读
提问者采纳
forty-six thousand and forty one
forty-six thousand
one hundred and sixty
fifty-two thousand three hundred and eighty希望帮
我现在在韩国呢
不会说韩语啊
不知道这是什么意思啊
你发的是什么啊 我没看懂啊
能不能发中国字啊
不好意思哦··我不会写谐音~你就按照汉语拼音的读法就Ok了····记住th 读s,gh 不发音
提问者评价
来自团队:
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Ionic and Cordova's DeviceReady - My Solution
Folks know that I've been madly in love with the Ionic framework lately, but I've run into an issue that I'm having difficulty with. I thought I'd blog about the problem and demonstrate a solution that worked for me. To be clear, I think my solution is probably wrong . It works, but it just doesn't feel right. I'm specifically sharing this blog entry as a way to start the discussion and get some feedback. On the slim chance that what I'm showing is the best solution... um... yes... I planned that. I'm brilliant. The Problem So let's begin by discussing the problem. Given a typical Ionic app, your Angular code will have a .run method that listens for the ionicPlatform's ready event. Here is an example from the &base& starter app ( /driftyco/ionic-app-base/blob/master/www/js/app.js ): // Ionic Starter App// angular.module is a global place for creating, registering and retrieving Angular modules// 'starter' is the name of this angular module example (also set in a &body& attribute in index.html)// the 2nd parameter is an array of 'requires'angular.module('starter', ['ionic']).run(function($ionicPlatform) {$ionicPlatform.ready(function() {// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard// for form inputs)if(window.cordova && window.cordova.plugins.Keyboard) {cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);}if(window.StatusBar) {// Set the statusbar to use the default style, tweak this to// remove the status bar on iOS or change it to use white instead of dark colors.StatusBar.styleDefault();}});})The ionicPlatform.ready event is called when Cordova's deviceready event fires. When run on a desktop, it is fired when on window.load. Ok, so in my mind, this is where I'd put code that's normally in a document.ready block. So far so good. Now let's imagine you want to use a plugin, perhaps the Device plugin. Imagine you want to simply copy a value to $scope so you can display it in a view. If that controller/view is the first view in your application, you end up with a race condition. Angular is going to display your view and fire off ionicPlatform.ready asynchronously. That isn't a bug of course, but it raises the question. If you want to make use of Cordova plugin features, and your application depends on it immediately , how do you handle that easily? One way would be to remove ng-app from the DOM and bootstrap Angular yourself. I've done that... once before and I see how it makes sense. But I didn't want to use that solution this time as I wanted to keep using ionicPlatform.ready. I assumed (and I could be wrong!) that I couldn't keep that and remove the ng-app bootstraping.So what I did was to add an intermediate view to my application. A simple landing page. I modified the stateProvider to add a new state and then made it the default. In my ionicPlatform.ready, I use the location service to do a move to the previously default state..run(function($ionicPlatform,$location,$rootScope) {$ionicPlatform.ready(function() {// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard// for form inputs)if(window.cordova && window.cordova.plugins.Keyboard) {cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);}if(window.StatusBar) {// org.apache.cordova.statusbar requiredStatusBar.styleDefault();} $location.path('/tab/dash'); $rootScope.$apply();});})This seemed to do the trick. My controller code that's run for the views after this were able to use Cordova plugins just fine. How about a real example?The Demo One of the more recent features to land in Ionic are striped-style tabs . This is an Android-style tab UI and it will be applied automatically to apps running on Android. The difference is a bit subtle when the tabs are on the bottom:
But when moved to the top using tabs-top, it is a bit more dramatic.
Ok... cool. But I wondered - how can I get tabs on top just for Android? While I'm not one of those people who believe that UI elements have to be in a certain position on iOS versus Android, I was curious as to how I'd handle this programatically. Knowing that it was trivial to check the Device plugin, and having a way now to delay the view until my plugins were loaded, I decided to use the approach described above to ensure I could access the platform before that particular view loaded.Here is the app.js file I used, modified from the tabs starter template.// Ionic Starter App// angular.module is a global place for creating, registering and retrieving Angular modules// 'starter' is the name of this angular module example (also set in a &body& attribute in index.html)// the 2nd parameter is an array of 'requires'// 'starter.services' is found in services.js// 'starter.controllers' is found in controllers.jsangular.module('starter', ['ionic', 'starter.controllers', 'starter.services']).run(function($ionicPlatform,$location,$rootScope) {$ionicPlatform.ready(function() {// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard// for form inputs)if(window.cordova && window.cordova.plugins.Keyboard) {cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);}if(window.StatusBar) {// org.apache.cordova.statusbar requiredStatusBar.styleDefault();} $location.path('/tab/dash'); $rootScope.$apply();});}).config(function($stateProvider, $urlRouterProvider) {// Ionic uses AngularUI Router which uses the concept of states// Learn more here: /angular-ui/ui-router// Set up the various states which the app can be in.// Each state's controller can be found in controllers.js$stateProvider// setup an abstract state for the tabs directive .state('home', {
url:&/home&,
templateUrl:'templates/loading.html',
controller:'HomeCtrl' }).state('tab', {url: &/tab&,abstract: true,templateUrl: function() {
if(window.device.platform.toLowerCase().indexOf(&android&) &= 0) {
return &templates/tabs_android.html&;
return &templates/tabs.html&;
} },})// Each tab has its own nav history stack:.state('tab.dash', {url: '/dash',views: {'tab-dash': {templateUrl: 'templates/tab-dash.html',controller: 'DashCtrl'}}}).state('tab.friends', {url: '/friends',views: {'tab-friends': {templateUrl: 'templates/tab-friends.html',controller: 'FriendsCtrl'}}}).state('tab.friend-detail', {url: '/friend/:friendId',views: {'tab-friends': {templateUrl: 'templates/friend-detail.html',controller: 'FriendDetailCtrl'}}}).state('tab.account', {url: '/account',views: {'tab-account': {templateUrl: 'templates/tab-account.html',controller: 'AccountCtrl'}}});// if none of the above states are matched, use this as the fallback$urlRouterProvider.otherwise('/home');}); You can see where I use the location.path mechanism after the ionicPlatform.ready event has fired. You can also see where I sniff the device platform to determine which template to run. tabs_android.html is the exact same as tabs.html - but with the tabs-top class applied (*). The biggest drawback here is that the application would error when run on the desktop. That could be avoided by sniffing for the lack of window.device and just setting it to some default: window.device = {platform : &ios&};
So that's it. What do you think? I have to imagine there is a nicer way of handling this. Maybe I'm being lazy but I want to use Ionic's killer directives and UX stuff along with Cordova plugins and not have to use an awkward workaround like this.
* A quick footnote. I noticed that if I tried to add tabs-top to the ion-tabs directive, it never worked. For example, this is what I tried first: &ion-tabs ng-class=&{'tabs-top':settings.isAndroid}&& I used code in my controller that always set it to true (I wasn't worried about the device plugin yet) and it never actually updated the view. It's like the controller scope couldn't modify the view for some odd reason.
无相关信息
最新教程周点击榜
微信扫一扫

我要回帖

更多关于 杨思路1279号 的文章

 

随机推荐