2016年4月27日星期三

Android RatingBar自定义星星


1. 添加自定义 drawable
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+android:id/background"        android:drawable="@mipmap/img_rating_off" />
这个需要注意的是 如果想显示一半的话 需要加下面内容    <item        android:id="@+android:id/secondaryProgress"        android:drawable="@mipmap/img_rating_off">    </item>
    <item android:id="@+android:id/progress"        android:drawable="@mipmap/img_rating_on" />
</layer-list>


2.添加style
 >Height里要注意的是 最好要跟星图片的大小一致
<style name="ManagerRatingStyle" parent="@android:style/Widget.RatingBar">    <item name="android:progressDrawable">@drawable/ratingbar_drawable</item>    <item name="android:numStars">5</item>    <item name="android:minHeight">34px</item>    <item name="android:maxHeight">34px</item></style>


3. 拿过来使用
 >numStars表示 星数
 >rating:评星枫树
 >stepSize: 操作星的单位
<RatingBar    android:layout_marginTop="@dimen/dp5"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_marginLeft="10dip"    android:id="@+id/ratingbar"    style="@style/ManagerRatingStyle"    android:numStars="5"    android:rating="3.5"    android:stepSize="0.5"    />




2016年4月12日星期二

Android Studio 环境使用

1. Editor设置
>Colors & Fonts > General > Problem from server 取消
>设置Show line numbers
  General > Appearance > Show line numbers

2016年4月6日星期三

Android 使用 in-app(google 支付)

本教程是完成最基本的操作为目的 写的博客。

1. 启用谷歌给的 sample代码.让他运转起来为目的. 
   如果你的项目要使用的话 直接把代码copy到 你的项目就行. 但是要注意的几点还是会
   写上的.
   
  sample下载地址:https://github.com/googlesamples/android-play-billing


2. 获取谷歌的 Licence Key
   >首先进入 https://play.google.com/apps/publish/ 选择应用(如果没有的话创建)
     进入 서비스 및 API 查看 License Key
    




3. 打开从git下载的 sample项目把License添加进去


   

4. 之后就是要给 你的应用添加 购物ITEM

4-1: 首先进入 你的google 控制台添加 购物item并获取 ITEM ID码

 添加: 添加的时候 제품ID就是 你的购物item ID


并把item ID添加到代码里


之后运行你的项目并执行购物的代码。



购买结果将在以下接口里 回调。




至此安卓端的 应用算完成了.



开发过程中的 注意点                                            

1.你的谷歌应用必须得是发布的状态.
2.packageName与你的applicationId是相同的(待验证)
3.如果想测试的话 你的应用状态必须是 alpha或者beta状态下才能免费购买
4.如果想直接查看结果的话商品ID设置 android.test.purchased
  这么做的话只能完成一次,并且下次无法使用


如果想查看 收入状况的话(Payments 판매자 센터)
https://payments.google.com/

下面是关于sample代码的一些注解

1.
IabHelper.OnIabPurchaseFinishedListener
这方法当中有个 Purchase 。这个是 订单完成时候回调过来的订单信息
里边有个 Purchase.mOrderId 这个可以在 Payments 판매자 센터订单当中可以匹配。
但是如果调试的话 这个数据是NULL的。只有在发布完应用以后,下载那个应用才能有数据


2. 实力当中 有 SKU_PREMIUM 与 SKU_GAS 分别对应的是  





2016年4月5日星期二

使用 gradle 编译指定keystore

在开发的时候 默认用的是 debug.keystore.
如果想用自己的签名包 运行时 打包的话 就要在 buld.gradle设置以下
(使用android studio 为什么要用命令行呢? 呵呵)

signingConfigs {
    
    debug{
        storeFile file('D:/project/android-play-billing-master/TrivialDrive/kirstore.jks')
        keyAlias 'kirsong'        keyPassword "china123"        storePassword "china123"    }
}

以上是 debug模式上。如果想在 使用命令行 使用签名包的话就要用到 以下命令

注意上下顺序.

signingConfigs {
    release {
        storeFile file('D:/project/android-play-billing-master/TrivialDrive/kirstore.jks')
        keyAlias 'kirsong'        keyPassword "china123"        storePassword "china123"    }
}

buildTypes {
    release {
        /**使用 以下命名方式*/        signingConfig signingConfigs.release
    }
}