小编Cot*_*nyo的帖子

处理Android应用内结算中的订阅更改

假设我的用户有4个月的订阅.在其中的一个月内,她希望转向年度订阅.谷歌播放应用内结算如何处理这个问题?有没有办法将用户从一个订阅移动到另一个订阅?我正在考虑可能的计费错误的实际影响,例如对用户过度收费等.仅向用户收取4个月订阅的1/4然后取消它然后开始年度版本的想法.应用内结算处理这些问题吗?

android subscription in-app-purchase in-app-billing

5
推荐指数
0
解决办法
283
查看次数

使用layer-list创建渐变笔触

我正在尝试使用图层列表创建渐变笔触(即周边/边框)作为我视图的背景.但它不起作用.

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <gradient
                android:angle="270"
                android:centerColor="#FFFFFFFF"
                android:endColor="#FFCCCCCC"
                android:startColor="#FFCCCCCC"
                android:type="linear" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#F0F1F3" />

            <margin
                android:bottom="4dp"
                android:left="4dp"
                android:right="4dp"
                android:top="4dp" />
        </shape>
    </item>

</layer-list>
Run Code Online (Sandbox Code Playgroud)

第一项完全不可见.只有第二项填充屏幕.有关如何解决此问题的任何想法?

android gradient shape android-layout

4
推荐指数
2
解决办法
1万
查看次数

在android中创建带有两个角形边的形状

我正在尝试创建一个具有两个圆形边缘和两个锐边的形状.但我不断收到以下错误:

The graphics preview in the layout editor may not be accurate:
Different corner sizes are not supported in Path.addRoundRect.
Run Code Online (Sandbox Code Playgroud)

这是代码

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="#888888" >
    </solid>

    <stroke
        android:width="2dp"
        android:color="#C4CDE0" >
    </stroke>

    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" >
    </padding>

    <corners
        android:bottomLeftRadius="11dp"
        android:topLeftRadius="11dp" >
    </corners>

</shape>
Run Code Online (Sandbox Code Playgroud)

android rounded-corners android-layout

3
推荐指数
1
解决办法
5741
查看次数

使用android MAC地址作为唯一标识符

我一直在阅读有关android没有唯一标识符的stackoverflow上的一些帖子.但我不能将设备的MAC地址用作唯一ID吗?如果没有,为什么不呢?如果是的话,是否有人知道如何以编程方式获取它(即一段代码[请])?

供参考:

我的应用程序需要网络,因此没有网络的设备将无法安装它.

android mac-address

3
推荐指数
1
解决办法
7968
查看次数

listview count vs android中的适配器数量

为什么listview.getChildCount()adapter.getCount()返回不同的值?我有一个onScroll方法,如果我调用上面的方法,每个方法返回不同的值.有谁知道为什么?

android android-arrayadapter android-layout android-listview android-adapter

3
推荐指数
1
解决办法
5440
查看次数

将RelativeLayout Relative设置为GONE不会影响子项

我有一个RelativeLayout,叫它my_rel,有很多孩子.我使用include标签将其包含my_rel到另一个布局中.无论如何,当我将my_rel可见度设定为GONE时,my_rel仍然可以看到孩子们?我该如何防止这种情况发生?

这是更大的/包络视图:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F0F1F3"
    tools:context=".CookingFiest" >

    <View
        android:layout_width="1dp"
        android:layout_height="fill_parent"
        android:layout_marginLeft="84dp"
        android:background="#CCCCCC" />

    <View
        android:layout_width="4dp"
        android:layout_height="fill_parent"
        android:layout_marginLeft="85dp"
        android:background="#FFFFFFFF" />

    <View
        android:layout_width="1dp"
        android:layout_height="fill_parent"
        android:layout_marginLeft="89dp"
        android:background="#CCCCCC" />

    <ScrollView
        android:id="@+id/my_scroller"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dip"
        android:isScrollContainer="false" >

        <LinearLayout
            android:id="@+id/timeline_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />
    </ScrollView>

    <com.nothing.noevil.widget.HorizontalListView
        android:id="@+id/cool_stuff"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_above="@id/cool_stuff"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp" />

    <include
        android:id="@+id/appliance"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        layout="@layout/kitchen" />

    <RelativeLayout
        android:id="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="10dp"
        android:background="#00000000"
        android:clickable="true" >

        <ImageView
            android:id="@+id/cook"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android relativelayout android-layout

2
推荐指数
1
解决办法
7603
查看次数

如何在android中设置ImageView背景

我正在使用API​​级别14. setBackgroundDrawable已弃用且setBackground抱怨为API级别16.那么我可以使用什么来设置我的背景可绘制?

android android-layout android-drawable

2
推荐指数
1
解决办法
7101
查看次数

哪个EditText方法侦听输入的每个字母

我有一个EditText.我setOnEditorActionListener用来收听用户输入的每个字母.但这似乎并没有奏效.我在函数中放置了一个println语句来查看它已到达,但它从未调用过.这是EditText.缺少什么?

    <EditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="5dp"
            android:drawableRight="@drawable/my_img"
            android:hint="@string/email_hint"
            android:imeActionId="@+id/login"
            android:inputType="textNoSuggestions|textVisiblePassword"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="#000000" />
Run Code Online (Sandbox Code Playgroud)

android android-layout android-edittext

2
推荐指数
1
解决办法
753
查看次数

以编程方式更改菜单项在android中无效

我有一个菜单项,我想以编程方式更改其可见性.菜单就是这个

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > 
     <item
        android:id="@+id/pencil"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:visible="true"
        android:title="@string/for_pencil"/>

</menu>
Run Code Online (Sandbox Code Playgroud)

然后我的代码中的一些地方

((MenuItem) findViewById(R.id. pencil)).setVisible(false);
Run Code Online (Sandbox Code Playgroud)

错误:

E/AndroidRuntime(13845): FATAL EXCEPTION: main
E/AndroidRuntime(13845): java.lang.ClassCastException: com.android.internal.view.menu.ActionMenuItemView cannot be cast to android.view.MenuItem
Run Code Online (Sandbox Code Playgroud)

任何帮助整理出来的?

android menuitem android-layout

1
推荐指数
1
解决办法
5678
查看次数

使用静态内部类创建java单例

我想使用以下模式在java中创建单例

public class Singleton {
        // Private constructor prevents instantiation from other classes
        private Singleton() { }

        /**
        * SingletonHolder is loaded on the first execution of Singleton.getInstance() 
        * or the first access to SingletonHolder.INSTANCE, not before.
        */
        private static class SingletonHolder { 
                public static final Singleton INSTANCE = new Singleton();
        }

        public static Singleton getInstance() {
                return SingletonHolder.INSTANCE;
        }
}
Run Code Online (Sandbox Code Playgroud)

但是当我想调用的私有构造函数发生时会发生什么

 private Singleton(Object stuff) {... }
Run Code Online (Sandbox Code Playgroud)

我怎么传递stuffINSTANCE = new Singleton()?如在INSTANCE = new Singleton(stuff);

重写上面的代码段: …

java singleton android

1
推荐指数
1
解决办法
8801
查看次数